Git Product home page Git Product logo

freshbooksrequest-php-api's Introduction

FreshBooksRequest PHP API

This class is meant to give you the ability to quickly access the FreshBooks API.

Usage

  • You need to know the method names and params when you're creating a new FreshBooksRequest instance. See all here http://developers.freshbooks.com/
  • The XML tag parameters you see on the freshbooks API page are the ones you pass to $fb->post() (as an array)
  • Require the lib and setup with your credentials (domain and token)
require('lib/FreshBooksRequest.php');

$domain = 'your-subdomain'; // https://your-subdomain.freshbooks.com/
$token = '1234567890'; // your api token found in your account
FreshBooksRequest::init($domain, $token);
/**********************************************
 * Fetch all clients by a specific id
 **********************************************/
// Method name found on the freshbooks API
$fb = new FreshBooksRequest('client.list');
// Any arguments you want to pass it
$fb->post(array(
    'email' => '[email protected]'
));
// Make the request
$fb->request();
if($fb->success())
{
    echo 'successful! the full response is in an array below';
    print_r($fb->getResponse());
}
else
{
    echo $fb->getError();
    print_r($fb->getResponse());
}
  • If you're creating a recurring profile with multiple line items, it might look something like this:
/**********************************************
 * Create a recurring profile with multiple line items
 **********************************************/
$fb = new FreshBooksRequest('recurring.create');
$fb->post(array(
    'recurring' => array(
        'client_id' => 41,
        'lines' => array(
            'line' => array(
                array(
                    'name' => 'A prod name',
                    'description' => 'The description',
                    'unit_cost' => 10,
                    'quantity' => 2
                ),
                array(
                    'name' => 'Another prod name',
                    'description' => 'The other description',
                    'unit_cost' => 20,
                    'quantity' => 1
                )
            )
        )
    )
));
// You can view what the XML looks like that we're about to send over the wire
//print_r($fb->getGeneratedXML());
$fb->request();
if($fb->success())
{
    $res = $fb->getResponse();
    $recurrng_id = $res['recurring_id'];
    // Do something with the recurring_id you were returned
}

Change Log

Changes in 1.0 (Sept 18, 2011)

  • Launched!

freshbooksrequest-php-api's People

Contributors

jboesch avatar lord-otori avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.