PHP Wrapper Library for Harvest API – Update: 0.2 Released !!

New Version released ! Get it Here.

I’ve been making enhancements since the initial release of the PHP Wrapper Library for the Harvest API, that I first released a week ago in my entry PHP Wrapper Library for the Harvest API. This 0.2 version of the wrapper library contains bug fixes for some issues that Jesse Mortenson of Supermega Design found, as well as implementation of the full API for Projects, Clients, and Client Contacts. Create and Delete functionality has been included for all other Harvest Objects but is currently untested.

Example Setup

  1. Require the HarvestAPI main class
    require_once( dirname(__FILE__) . '/HarvestAPI.php' );
  2. Register the Auto Loader
    spl_autoload_register(array('HarvestAPI', 'autoload') );
  3. Set Account & User information
    $api = new HarvestAPI();
    $api->setUser( "user@email.com" );
    $api->setPassword( "password" );
    $api->setAccount( "account" );

Example: Create a new Client

  1. Initialize and populate your Client Object
    $client = new Harvest_Client();
    $client->set( "name", "New Client" );
    $client->set( "details", "Our new Client" );
  2. Call create method
    $result = $api->createClient( $client );
  3. Check if request was successfull
    if( $result->isSuccess() ) {
      ...
    }
  4. If successful you will be returned the new Client’s Harvest ID
    $client_id = $result->data;

Example: Toggle a Projects active state

  1. Call toggle method with the Project’s Harvest ID
    $result = $api->toggleProject( $project_id );
  2. Check if request was successfull
    if( $result->isSuccess() ) {
      ...
    }

Contact

If you encounter bugs, or issues with the library please contact me with the details. I hope that you will find this useful and if you do feel free to leave a comment.

Download

Resources

// Harvest // PHP //

Comments & Questions

Add Your Comment