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
- Require the HarvestAPI main class
require_once( dirname(__FILE__) . '/HarvestAPI.php' );
- Register the Auto Loader
spl_autoload_register(array('HarvestAPI', 'autoload') );
- Set Account & User information
$api = new HarvestAPI(); $api->setUser( "user@email.com" ); $api->setPassword( "password" ); $api->setAccount( "account" );
Example: Create a new Client
- Initialize and populate your Client Object
$client = new Harvest_Client(); $client->set( "name", "New Client" ); $client->set( "details", "Our new Client" );
- Call create method
$result = $api->createClient( $client );
- Check if request was successfull
if( $result->isSuccess() ) { ... }
- If successful you will be returned the new Client’s Harvest ID
$client_id = $result->data;
Example: Toggle a Projects active state
- Call toggle method with the Project’s Harvest ID
$result = $api->toggleProject( $project_id );
- 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.
Comments & Questions
Add Your Comment