Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 1.91 KB

README.md

File metadata and controls

75 lines (55 loc) · 1.91 KB

basecamp.php

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.

Requirements

Getting Started

Download

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

Require

<?php
require 'path/to/basecamp.php/basecamp.php';
?>

Limitations

  • 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.

Usage

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.