错误:在运行此示例之前,请将域添加到App.Config(快速入门PHP SDK)

时间:2014-05-20 10:06:56

标签: quickbooks

我正在使用" 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++;
}

1 个答案:

答案 0 :(得分:0)

请参阅以下链接。

https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0210_ipp_php_sdk_for_quickbooks_v3/0002_synchronous_calls/0001_data_service_apis

您可以在以下代码段中对值进行硬编码,而不是从配置文件中读取值。

$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);

它应该有用。