-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexample.php
More file actions
84 lines (80 loc) · 1.98 KB
/
example.php
File metadata and controls
84 lines (80 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?
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());
}
?>