forked from IntuitDeveloper/QBOConceptsTutorial-PHP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomerAdd.php
68 lines (59 loc) · 1.93 KB
/
CustomerAdd.php
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
<?php
require_once(__DIR__ . '/vendor/autoload.php');
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\Facades\Customer;
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
session_start();
function customerAdd()
{
// Create SDK instance
$config = include('config.php');
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth2',
'ClientID' => $config['client_id'],
'ClientSecret' => $config['client_secret'],
'RedirectURI' => $config['oauth_redirect_uri'],
'scope' => $config['oauth_scope'],
'baseUrl' => "development"
));
/*
* Retrieve the accessToken value from session variable
*/
$accessToken = $_SESSION['sessionAccessToken'];
$dataService->setLogLocation("/Users/hlu2/Desktop/newFolderForLog");
$dataService->throwExceptionOnError(true);
/*
* Update the OAuth2Token of the dataService object
*/
$dataService->updateOAuth2Token($accessToken);
$theResourceObj = Customer::create([
"BillAddr" => [
"Line1" => "123 Main Street",
"City" => "Mountain View",
"Country" => "USA",
"CountrySubDivisionCode" => "CA",
"PostalCode" => "94042"
],
"Notes" => "Here are other details.",
"Title" => "Mr",
"GivenName" => "JamesCRUD",
"MiddleName" => "B",
"FamilyName" => "KingCRUD",
"Suffix" => "Jr",
"FullyQualifiedName" => "JamesCRUD KingCRUD",
"CompanyName" => "King Groceries CRUD",
"DisplayName" => "JamesCfdRdUDesf KingCRUD",
"PrimaryPhone" => [
"FreeFormNumber" => "(555) 555-5555"
],
"PrimaryEmailAddr" => [
"Address" => "[email protected]"
]
]);
$resultingObj = $dataService->Add($theResourceObj);
$result = json_encode($resultingObj, JSON_PRETTY_PRINT);
print_r($result);
return $result;
}
$result = customerAdd();
?>