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"); } // Run a query $entities = $dataService->Query("SELECT * FROM TaxRate"); // Echo some formatted output if (count($entities) > 0) { $i = 0; foreach ($entities as $oneTaxRate) { echo "TaxRate[{$i}] Name: {$oneTaxRate->Name}\tRate {$oneTaxRate->RateValue} AgencyRef {$oneTaxRate->AgencyRef} (SpecialTaxType {$oneTaxRate->SpecialTaxType})\n"; $i++; } } /* Example output: TaxRate[0] Name: NOTAXP Rate 0 AgencyRef 1 (SpecialTaxType NO_TAX) TaxRate[1] Name: NOTAXS Rate 0 AgencyRef 1 (SpecialTaxType NO_TAX) TaxRate[2] Name: Purchase EC 2% Rate 2 AgencyRef 3 (SpecialTaxType NONE) TaxRate[3] Name: Purchase HEC 1% Rate 1 AgencyRef 3 (SpecialTaxType NONE)
} // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Build a query $oneQuery = new QueryMessage(); $oneQuery->sql = "SELECT"; $oneQuery->entity = "Customer"; $oneQuery->orderByClause = "FamilyName"; $oneQuery->startposition = "1"; $oneQuery->maxresults = "4"; // Run a query $queryString = $oneQuery->getString(); $entities = $dataService->Query($queryString); // Echo some formatted output $i = 0; if ($entities) { foreach ($entities as $oneCustomer) { echo "Customer[{$i}] GivenName: {$oneCustomer->GivenName}\t(Created at {$oneCustomer->MetaData->CreateTime})\n"; $i++; } } /* Example output: Customer[0] GivenName: Jimco LLC (Created at 2013-06-29T22:06:45-07:00) Customer[1] GivenName: ACME Corp (Created at 2013-06-29T22:10:18-07:00) Customer[2] GivenName: Smithco Inc. (Created at 2013-06-29T22:11:57-07:00) Customer[3] GivenName: Special Inc. (Created at 2013-06-29T22:13:34-07:00)
$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"); } // Run a query $entities = $dataService->Query("SELECT * FROM Customer"); // Echo some formatted output $i = 0; foreach ($entities as $oneCustomer) { echo "Customer[{$i}] DisplayName: {$oneCustomer->DisplayName}\t(Created at {$oneCustomer->MetaData->CreateTime})\n"; $i++; } /* Example output: Customer[0] GivenName: Jimco LLC (Created at 2013-06-29T22:06:45-07:00) Customer[1] GivenName: ACME Corp (Created at 2013-06-29T22:10:18-07:00) Customer[2] GivenName: Smithco Inc. (Created at 2013-06-29T22:11:57-07:00) Customer[3] GivenName: Special Inc. (Created at 2013-06-29T22:13:34-07:00) */