我正在使用" PHP v3 SDK for QBO"。我编辑了_sample文件夹中的customer_query.php&改变了
RealmID (**Company id given**), AccessToken,AccessTokenSecret,ConsumerKey,ConsumerSecret
(当我测试连接到应用程序时,我得到了这些值)。但我收到错误Please add realm to App.Config before running this sample
。即使我给了公司ID,我也会收到这个错误。
这是我的代码:
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('55555555'); // **Company id given**
if (!$realmId)
exit("**Please add realm to App.Config before running this sample**.\n"); // ***My code stop here***
// Prep Service Context
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'),
ConfigurationManager::AppSettings('AccessTokenSecret'),
ConfigurationManager::AppSettings('ConsumerKey'),
ConfigurationManager::AppSettings('ConsumerSecret')); // **Actual key given**
$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] GivenName: {$oneCustomer->GivenName} (Created at {$oneCustomer->MetaData->CreateTime})\n";
$i++;
}
答案 0 :(得分:0)
请参阅以下链接。
您可以在以下代码段中对值进行硬编码,而不是从配置文件中读取值。
$accessToken = '';
$accessTokenSecret = '';
$consumerKey = '';
$consumerSecret = '';
$requestValidator = new OAuthRequestValidator(
$accessToken, $accessTokenSecret, $consumerKey, $consumerSecret);
$realmId = '';
$serviceType= IntuitServicesType::QBO;
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$dataService = new DataService($serviceContext);
它应该有用。