1. Go to this page and download the library: Download hlu2/quick-books_demo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hlu2 / quick-books_demo example snippets
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
use QuickBooksOnline\API\Data\IPPCustomer;
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth1',
'consumerKey' => "Your Cosumer Key",
'consumerSecret' => "Your Consumer secrets",
'accessTokenKey' => "Your Access Token",
'accessTokenSecret' => "Your Access Token Secrets",
'QBORealmID' => "193514489870599",
'baseUrl' => "https://sandbox.api.intuit.com/"
));
if (!$dataService)
exit("Problem while initializing DataService.\n");
// Add a customer
$customerObj = new IPPCustomer();
$customerObj->Name = "Name" . rand();
$customerObj->CompanyName = "CompanyName" . rand();
$customerObj->GivenName = "GivenName" . rand();
$customerObj->DisplayName = "DisplayName" . rand();
$resultingCustomerObj = $dataService->Add($customerObj);
$error = $dataService->getLastError();
if ($error != null) {
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
echo "The Response message is: " . $error->getResponseBody() . "\n";
}
else {
echo "Created Customer Id={$resultingCustomerObj->Id}. Reconstructed response body:\n\n";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingCustomerObj, $urlResource);
echo $xmlBody . "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.