Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

84 lines (80 sloc) 2.028 kb
<?
require('lib/FreshBooksRequest.php');
// Setup the login credentials
$domain = '';
$token = '';
FreshBooksRequest::init($domain, $token);
/**********************************************
* Fetch all clients by a specific id
**********************************************/
$fb = new FreshBooksRequest('client.list');
$fb->post(array(
'email' => 'some@email.com'
));
$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());
}
/**********************************************
* List invoices from a specific client
**********************************************/
$fb = new FreshBooksRequest('invoice.list');
$fb->post(array(
'client_id' => 41
));
$fb->request();
if($fb->success())
{
print_r($fb->getResponse());
}
else
{
echo $fb->getError();
print_r($fb->getResponse());
}
/**********************************************
* 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
)
)
)
)
));
//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
}
else
{
echo $fb->getError();
print_r($fb->getResponse());
}
?>
Jump to Line
Something went wrong with that request. Please try again.