<?php

include_once 'include/init.php';
//include particular file for entity you need (Client, Invoice, Category...)
include_once LIB_PATH . "/FreshBooks/Invoice.php";
$clientId = 4;
//new Invoice object
$invoice = new FreshBooks_Invoice();
//populate data
$invoice->clientId = $clientId;
$invoice->date = '2011-05-06';
//mysql format
//all other required properties should be populated
//lines (items) is array of asoc. arrays
$invoice->lines = array(array('name' => 'xyz', 'unitCost' => 99.98999999999999), array('name' => 'yyy', 'unitCost' => 199.99));
//try to create new invoice with provided data on FB server
if (!$invoice->create()) {
    //read error
    echo $invoice->lastError;
} else {
    //investigate populated data
    print_r($invoice);
}
Beispiel #2
0
 /**
  * process XML string response from LIST server method
  */
 protected function _internalListing($responseStatus, &$XMLObject, &$rows, &$resultInfo)
 {
     $rows = array();
     $resultInfo = array();
     $invoices = $XMLObject->invoices;
     $resultInfo['page'] = (string) $invoices['page'];
     $resultInfo['perPage'] = (string) $invoices['per_page'];
     $resultInfo['pages'] = (string) $invoices['pages'];
     $resultInfo['total'] = (string) $invoices['total'];
     foreach ($invoices->children() as $key => $currXML) {
         $thisInvoice = new FreshBooks_Invoice();
         $thisInvoice->_internalLoadXML($currXML);
         $rows[] = $thisInvoice;
     }
 }
<?php

include_once 'include/init.php';
//include particular file for entity you need (Client, Invoice, Category...)
include_once LIB_PATH . "/FreshBooks/Invoice.php";
$invoiceId = 4;
//new Invoice
$invoice = new FreshBooks_Invoice();
//try to get invoice id: $invoiceId
if (!$invoice->get($invoiceId)) {
    //no data - read error
    echo $invoice->lastError;
} else {
    //investigate populated data
    print_r($invoice);
    print_r($invoice->sendByEmail('Test invoice', "Hello"));
}