PHP Classes

Push data to Intuit (QuickBooks)

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  Learn with a PHP OAut...  >  All threads  >  Push data to Intuit (QuickBooks)  >  (Un) Subscribe thread alerts  
Subject:Push data to Intuit (QuickBooks)
Summary:How to push data to QuciBooks using CallAPI
Messages:4
Author:Murray Russell
Date:2017-02-22 10:02:53
 

  1. Push data to Intuit (QuickBooks)   Reply   Report abuse  
Picture of Murray Russell Murray Russell - 2017-02-22 10:02:53
Many thanks to Manuel Lemos for a very useful class. I am successfully connecting to QuickBooks Online using its OAuth facilities and pulling the list of Customers. I now need to add a new customer and add invoices.

If I read the Intuit API documents correctly I need to use

quickbooks.api.intuit.com/v3/compan ...

and pass the following for a new customer (in the Sandbox at present)

{
"BillAddr": {
"Line1": "123 Main Street",
"City": "Mountain View",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"PostalCode": "94042"
},
"Notes": "Here are other details.",
"Title": "Mr",
"GivenName": "James",
"MiddleName": "B",
"FamilyName": "King",
"Suffix": "Jr",
"FullyQualifiedName": "King Groceries",
"CompanyName": "King Groceries",
"DisplayName": "King's Groceries",
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"PrimaryEmailAddr": {
"Address": "jdrew@myemail.com"
}
}

but cannot see how to pass these details using CallAPI.

If anyone has successfully done this, could they please let me know how they did it.

  2. Re: Push data to Intuit (QuickBooks)   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2017-02-22 11:43:36 - In reply to message 1 from Murray Russell
You need to set the ResponseContentType option to application/json and pass an object of stdClass as parameters. Something like:

$parameters = new stdClass;
$parameters->DisplayName = "King's Groceries";
// ..
$success = $client->CallAPI(
'https://quickbooks.api.intuit.com/v3/company/%3Crealmid%3E/customer',
'POST',
$parameters,
array(
'FailOnAccessError'=>true,
'RequestContentType'=>'application/json'
), $customer);

  3. Re: Push data to Intuit (QuickBooks)   Reply   Report abuse  
Picture of Murray Russell Murray Russell - 2017-02-22 16:52:47 - In reply to message 2 from Manuel Lemos
Many thanks indeed. Fundamentally that worked. I have a few wrinkles to iron out like how to portray child data

"PrimaryEmailAddr": {
"Address": "jdrew@myemail.com"

in $parameters.

Where the item is first level, it works fine. Once again, thank you for your assistance.

  4. Re: Push data to Intuit (QuickBooks)   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2017-02-22 21:18:02 - In reply to message 3 from Murray Russell
You need to create separate objects for each of those object entries because PHP does not have a way to define constant objects like there is for arrays.

$email = new stdClass;
$email->Address = "jdrew@myemail.com";
$parameters->PrimaryEmailAddr = $email;