-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmployeeCreate.php
executable file
·65 lines (55 loc) · 2.6 KB
/
EmployeeCreate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
</head>
<body>
<?php
require_once('../v3-php-sdk-2.0.5/config.php');
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');
//Specify QBO or QBD
$serviceType = IntuitServicesType::QBO;
// Get App Config
$realmId = ConfigurationManager::AppSettings('RealmID');
if (!$realmId)
exit("Please add realm to App.Config before running this sample.\n");
// Prep Service Context
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'),
ConfigurationManager::AppSettings('AccessTokenSecret'),
ConfigurationManager::AppSettings('ConsumerKey'),
ConfigurationManager::AppSettings('ConsumerSecret'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
if (!$serviceContext)
exit("Problem while initializing ServiceContext.\n");
// Prep Data Services
$dataService = new DataService($serviceContext);
if (!$dataService)
exit("Problem while initializing DataService.\n");
// Add an employee
$employeeObj = new IPPEmployee();
$employeeObj->Name = "Employee";
$employeeObj->FamilyName = "Intuit";
$employeeObj->GivenName = "Employee";
$employeeObj->DisplayName = "Emp".rand();
$resultingEmployeeObjObj = $dataService->Add($employeeObj);
// Echo some formatted output
echo '<a href="javascript:void(0)" onclick="goHome()">Home</a>';
echo ' ';
echo '<a href="javascript:void(0)" onclick="return intuit.ipp.anywhere.logout(function () { window.location.href = \'http://localhost/PHPSample/index.php\'; });">Sign Out</a> ';
echo ' ';
echo '<a target="_blank" href="http://localhost/PHPSample/ReadMe.htm">Read Me</a><br />';
echo "<br />Created Employee in QuickBooks with Id={$resultingEmployeeObjObj->Id} and Name={$resultingEmployeeObjObj->DisplayName}<br /> <br /> Reconstructed response body:<br />";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingEmployeeObjObj, $urlResource);
echo $xmlBody . "\n";
?>
<script type="text/javascript">
function goHome(){
window.location.href = "http://localhost/PHPSample/SampleAppHomePage.php";
}
</script>
</body>
</html>