Lightweight multi-paradigm PHP (JSON) client for the new Basecamp API.
Many thanks to Sandeep Shetty, whose Shopify client provided the inspiration and much of the code for this project.
- PHP 5.3 with cURL support.
Download the latest version of basecamp.php:
$ curl -L http://github.com/bdunlap/basecamp.php/tarball/master | tar xvz
$ mv bdunlap-basecamp.php-* basecamp.php
<?php
require 'path/to/basecamp.php/basecamp.php';
?>
- Currently supports private apps only.
- This is quick and dirty and will get you started. It does not do client-side caching, which you must implement per 37signals. Pull requests welcome.
Making API calls:
<?php
$appName = 'MyApp';
$appContact = '[email protected]';
$basecampAccountId = '999999999';
$basecampUsername = 'yourusername';
$basecampPassword = 'yourpassword';
$basecamp = basecamp_api_client($appName, $appContact,
$basecampAccountId, $basecampUsername, $basecampPassword);
try {
/**
* Get a list of all projects:
*/
$projects = $basecamp('GET', '/projects.json');
echo "Current list of projects:\n";
foreach ($projects as $project) {
echo "\t".$project->name."\n";
}
/**
* Create a new project:
*/
$project = array(
'name' => 'My new project!',
);
$newProject = $basecamp('POST', '/projects.json', $project);
echo "New project ID is {$newProject->id}\n";
} catch (Exception $e) {
die($e->getMessage());
}
?>
See the Basecamp API docs for more interactions.