CoreHelper.php 第 95 行中的 QuickBooks IdsException

QuickBooks IdsException in CoreHelper.php line 95

我正在使用 QuickBooks v3 PHP SDK 2.3.0。我使用了 The PHP League 的 OAuth 1.0 客户端,而不是使用 SDK 的方式,因为它更简单。不过,这并不重要。我已成功授权我的应用程序并保存凭据。

然而,当我按照 examples in the docs 进行操作时,似乎没有什么能正常工作。

在下面的每个示例中,我使用以下代码进行设置:

require_once(Path::assemble(
    $this->getDirectory(),
    'vendor/QuickBooks/v3-php-sdk-2.3.0/',
    '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');

$tokenCredentials = $this->storage->getYAML('quickbooks/token.yaml');
$consumerCredentials = [
    'key'    => $this->getConfig('oauth_consumer_key'),
    'secret' => $this->getConfig('oauth_consumer_secret'),
];

$requestValidator = new \OAuthRequestValidator(
    array_get($tokenCredentials, 'identifier'),
    array_get($tokenCredentials, 'secret'),
    array_get($consumerCredentials, 'key'),
    array_get($consumerCredentials, 'secret')
);

$oauth_response = $this->storage->getYAML('quickbooks/response.yaml');

$realmId        = array_get($oauth_response, 'realmId');
$serviceType    = \IntuitServicesType::QBD;
$serviceContext = new \ServiceContext($realmId, $serviceType, $requestValidator);

$dataService = new \DataService($serviceContext);

如果我倾倒并死去 $dataService,我会得到我的 DataService 对象。但是我尝试执行的任何查询 returns null:

$dataService->Query('SELECT * FROM Customer');
$dataService->Query('SELECT count (*) FROM Vendor');
$dataService->FindAll('Customer', 1, 10);
$dataService->Query('SELECT * FROM *');

最后一个例子是抛出 IdsException:

$customerObj              = new \IPPCustomer();
$customerObj->Name        = "Name" . rand();
$customerObj->CompanyName = "CompanyName" . rand();
$customerObj->GivenName   = "GivenName" . rand();
$customerObj->DisplayName = "DisplayName" . rand();

$resultingCustomerObj = $dataService->Add($customerObj);

错误:

/DataService/DataService.php - 463 - CheckNullResponseAndThrowException - Response Null or Empty

我的问题是我没有更新 sdk.config 来使用沙盒 URL。

<baseUrl qbd="https://sandbox-quickbooks.api.intuit.com/" qbo="https://sandbox-quickbooks.api.intuit.com/" ipp="https://appcenter.intuit.com/api/" />

现在我只需要想办法根据环境自动使用合适的URL…