} // 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"); } // Iterate through all Customers, even if it takes multiple pages $i = 0; while (1) { $allCustomers = $dataService->FindAll('Customer', $i, 500); if (!$allCustomers || 0 == count($allCustomers)) { break; } foreach ($allCustomers as $oneCustomer) { echo "Customer[" . $i++ . "]: {$oneCustomer->CompanyName}\n"; echo "\t * Id: [{$oneCustomer->Id}]\n"; echo "\t * Active: [{$oneCustomer->Active}]\n"; echo "\n"; } } /* Example output: Customer[0]: JIMCO * Id: [NG:953957] * Active: [true]
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; require_once PATH_SDK_ROOT . 'QueryFilter/QueryMessage.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"); } $allCompanies = $dataService->FindAll('CompanyInfo'); foreach ($allCompanies as $oneCompany) { $oneCompanyReLookedUp = $dataService->FindById($oneCompany); echo "Company Name: {$oneCompanyReLookedUp->CompanyName}\n"; } /* Example output: Company Name: MyCo Production LLC Company Name: ACME Inc. Company Name: Jones Corp */
if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } echo '<table width="500" cellspacing="5" cellpadding="5" border="1">'; echo '<tr> <th>Name</th> <th> Number </th> <th>Type</th> <th> Subtype </th> </tr>'; // Iterate through all Accounts, even if it takes multiple pages $startPosition = 1; $maxResult = 1000; $count = 0; while (1) { $allAccounts = $dataService->FindAll('Account', $startPosition, $maxResult); if (!$allAccounts || 0 == count($allAccounts)) { break; } foreach ($allAccounts as $oneAccount) { $startPosition++; $count++; echo "<tr>"; echo "<td>{$oneAccount->Name}</td>"; echo "<td>{$oneAccount->Id}</td>"; echo "<td>{$oneAccount->AccountType}</td>"; echo "<td>{$oneAccount->AccountSubType}</td>"; echo '</tr>'; } } echo '<a href="javascript:void(0)" onclick="goHome()">Home</a>';
} // 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"); } // Iterate through all Accounts, even if it takes multiple pages $i = 1; while (1) { $allAccounts = $dataService->FindAll('Account', $i, 500); if (!$allAccounts || 0 == count($allAccounts)) { break; } foreach ($allAccounts as $oneAccount) { echo "Account[" . $i++ . "]: {$oneAccount->Name}\n"; echo "\t * Id: [{$oneAccount->Id}]\n"; echo "\t * AccountType: [{$oneAccount->AccountType}]\n"; echo "\t * AccountSubType: [{$oneAccount->AccountSubType}]\n"; echo "\t * Active: [{$oneAccount->Active}]\n"; echo "\n"; } } /* Example output: Account[0]: Travel Meals