<?php

include_once 'include/init.php';
//include particular file for entity you need (Client, Invoice, Category...)
include_once LIB_PATH . "/FreshBooks/Client.php";
//new Client object
$client = new FreshBooks_Client();
//populate client’s properties
$client->email = '*****@*****.**';
$client->firstName = 'Chad';
$client->lastName = 'Smith';
$client->organization = 'RHCP';
//all other required properties should be populated
//try to create new client with provided data on FB server
if (!$client->create()) {
    //read error
    echo $client->lastError;
} else {
    //investigate populated data
    print_r($client);
}
<?php

include_once 'include/init.php';
//include particular file for entity you need (Client, Invoice, Category...)
include_once LIB_PATH . "/FreshBooks/Client.php";
$clientId = 3;
//new Client object
$client = new FreshBooks_Client();
//try to get client with client_id $clientId
if (!$client->get($clientId)) {
    //no data - read error
    echo $client->lastError;
} else {
    //investigate populated data
    print_r($client);
}
 private static function get_client($form, $entry, $settings, $name_fields)
 {
     $client = new FreshBooks_Client();
     $email = strtolower($entry[$settings["meta"]["email"]]);
     $is_new = true;
     if ($settings["meta"]["update_client"]) {
         //is there an existing client with the same email? If so, use it, if not, create one
         $client->listing($all_clients, $result_info);
         foreach ($all_clients as $current_client) {
             if (strtolower($current_client->email) == $email) {
                 $client = $current_client;
                 $is_new = false;
                 break;
             }
         }
     }
     $client->email = esc_html(self::get_entry_value($settings["meta"]["email"], $entry, $name_fields));
     $client->firstName = esc_html(self::get_entry_value($settings["meta"]["first_name"], $entry, $name_fields));
     $client->lastName = esc_html(self::get_entry_value($settings["meta"]["last_name"], $entry, $name_fields));
     $client->organization = esc_html(self::get_entry_value($settings["meta"]["organization"], $entry, $name_fields));
     $address_field = $settings["meta"]["address"];
     if (!empty($address_field)) {
         $client->pStreet1 = esc_html($entry[$address_field . ".1"]);
         $client->pStreet2 = esc_html($entry[$address_field . ".2"]);
         $client->pCity = esc_html($entry[$address_field . ".3"]);
         $client->pState = esc_html($entry[$address_field . ".4"]);
         $client->pCode = esc_html($entry[$address_field . ".5"]);
         $client->pCountry = esc_html($entry[$address_field . ".6"]);
     }
     if (!empty($settings["meta"]["phone"])) {
         $client->workPhone = esc_html(self::get_entry_value($settings["meta"]["phone"], $entry, $name_fields));
     }
     if (!empty($settings["meta"]["fax"])) {
         $client->fax = esc_html(self::get_entry_value($settings["meta"]["fax"], $entry, $name_fields));
     }
     $client->notes = esc_html($settings["meta"]["notes"]);
     if ($is_new) {
         self::log_debug("Client not found; creating new client with email address {$email}.");
         $client->create();
         $lastError = $client->lastError;
         if (empty($lastError)) {
             self::log_debug("New client created.");
         } else {
             self::log_error("The following error occurred when trying to create a new client: {$lastError}");
         }
     } else {
         self::log_debug("Existing client found with email address {$email}, not creating new one.");
         $id = $client->clientId;
         $client->update();
         $client->clientId = $id;
     }
     return $client;
 }
 /**
  * process XML string response from LIST server method
  */
 protected function _internalListing($responseStatus, &$XMLObject, &$rows, &$resultInfo)
 {
     $rows = array();
     $resultInfo = array();
     $clients = $XMLObject->clients;
     $resultInfo['page'] = (string) $clients['page'];
     $resultInfo['perPage'] = (string) $clients['per_page'];
     $resultInfo['pages'] = (string) $clients['pages'];
     $resultInfo['total'] = (string) $clients['total'];
     foreach ($clients->children() as $key => $currXML) {
         $thisClient = new FreshBooks_Client();
         $thisClient->_internalLoadXML($currXML);
         $rows[] = $thisClient;
     }
 }
<?
//include particular file for entity you need (Client, Invoice, Category...)
include_once "library/FreshBooks/Client.php";

//you API url and token obtained from freshbooks.com
$url = "your-url-please-replace";
$token = "your-token-please-replace";

//init singleton FreshBooks_HttpClient
FreshBooks_HttpClient::init($url,$token);

//new Client object
$client = new FreshBooks_Client();

//try to get client with client_id 3
if(!$client->get(3)){
//no data - read error
	echo $client->lastError;
}
else{
//investigate populated data
	print_r($client);
}
?>
 private function get_client($form, $entry, $settings, $name_fields)
 {
     $client = new FreshBooks_Client();
     $email = strtolower($entry[$settings['meta']['email']]);
     $is_new = true;
     if ($settings['meta']['updateClient']) {
         $existing_clients = '';
         $result_info = '';
         // is there an existing client with the same email? If so, use it, if not, create one
         $email = $entry[$settings['meta']['email']];
         $client->listing($existing_clients, $result_info, 1, 1, array('email' => $email, 'username' => ''));
         if (!empty($existing_clients)) {
             $client = $existing_clients[0];
             $is_new = false;
         }
     }
     $client->email = esc_html($this->get_entry_value($settings['meta']['email'], $entry, $name_fields));
     $client->firstName = esc_html($this->get_entry_value($settings['meta']['firstName'], $entry, $name_fields));
     $client->lastName = esc_html($this->get_entry_value($settings['meta']['lastName'], $entry, $name_fields));
     $client->organization = esc_html($this->get_entry_value($settings['meta']['organization'], $entry, $name_fields));
     $address_field = $settings['meta']['address'];
     if (!empty($address_field)) {
         $client->pStreet1 = esc_html($entry[$address_field . '.1']);
         $client->pStreet2 = esc_html($entry[$address_field . '.2']);
         $client->pCity = esc_html($entry[$address_field . '.3']);
         $client->pState = esc_html($entry[$address_field . '.4']);
         $client->pCode = esc_html($entry[$address_field . '.5']);
         $client->pCountry = esc_html($entry[$address_field . '.6']);
     }
     if (!empty($settings['meta']['phone'])) {
         $client->workPhone = esc_html(self::get_entry_value($settings['meta']['phone'], $entry, $name_fields));
     }
     if (!empty($settings['meta']['fax'])) {
         $client->fax = esc_html(self::get_entry_value($settings['meta']['fax'], $entry, $name_fields));
     }
     $client->notes = esc_html(GFCommon::replace_variables($settings['meta']['notes'], $form, $entry, false, false, false, 'text'));
     if ($is_new) {
         $this->log_debug(__METHOD__ . "(): Client not found; creating new client with email address {$email}.");
         $client->create();
         $lastError = $client->lastError;
         if (empty($lastError)) {
             $this->log_debug(__METHOD__ . '(): New client created.');
         } else {
             $this->log_error(__METHOD__ . "(): The following error occurred when trying to create a new client: {$lastError}");
         }
     } else {
         $this->log_debug(__METHOD__ . "(): Existing client found with email address {$email}, not creating new one.");
         $id = $client->clientId;
         $client->update();
         $client->clientId = $id;
     }
     return $client;
 }