Beeminder API

Source
http://github.com/beeminder/beeminder-php-api/
Download zip   Download tar.gz

What It Is

beeminder-api is a PHP library that makes it easy to interact with the Beeminder API. It's still under development, but at the moment you can:

  • Fetch a list of goals
  • Fetch information about a single goal, including all data points
  • Add one or more data points to an existing goal

Usage

First you'll need to include the autoloader using the following snippet:

require_once '/path/to/lib/Beeminder/Autoloader.php';
Beeminder_Autoloader::register();
      

Just replace "/path/to/" with the actual path the API is stored in.

Once the autoloader is included and setup, it's time to create an instance of Beeminder_Client. After that, simply login using authorisation tokens (either OAuth or the private API token) and then call whatever method(s) you want. Here's an example of how to retrieve a user's goals:

// Include the autoloader
require_once dirname(__FILE__) . '/vendor/beeminder-api/lib/Beeminder/Autoloader.php';
Beeminder_Autoloader::register();

// Create new client
$api = new Beeminder_Client();

// Setup auth (private token)
$api->login(
    'username',
    'secret_token',
    Beeminder_Client::AUTH_PRIVATE_TOKEN
);

// Fetch a list of goals for the user
$goals = $api->getGoalApi()->getGoals();

// Output some happy info
foreach ($goals as $goal) {
    echo "{$goal->title}\n";
    echo "{$goal->goal_type}\n";
}
      

Projects that use this library

If you've built something using this library and would like to be featured here, let me know.

  • beeminder-ping – A WordPress plugin to ping Beeminder when a post is made.

Credits