Quickbooks 异常和错误(如何判断它们是什么?)
Quickbooks Exceptions & Errors (How to tell what they are?)
我正在使用 Quickbooks PHP SDK。
我目前正在尝试 运行 下面的命令:
$res = $dataService->Add($customerObj);
我知道命令现在正在抛出异常,但我不知道异常是什么或如何判断出了什么问题?
我该怎么做?
注意::我会自己弄清楚 customerObj 有什么问题以节省你们的时间,只需要弄清楚如何找出返回给我的错误是什么。
Update:: Its 异常错误,但不知道这是什么意思?
这里是代码的其余部分:
$requestValidator = new OAuthRequestValidator(
gdizDecrypt($qbkeys->oauthtoken),
gdizDecrypt($qbkeys->oauthtokensecret),
OAUTH_CONSUMER_KEY,
OAUTH_CONSUMER_SECRET
);
$serviceContext = new ServiceContext($qbkeys->realmid, $qbkeys->datasource, $requestValidator);
$dataService = new DataService($serviceContext);
$customerObj = new IPPCustomer();
$customerObj->GivenName = $client->contactfirstname.' '.$client->contactlastname;
$customerObj->FamilyName = $client->contactlastname;
$customerObj->DisplayName = $client->contactfirstname.' '.$client->contactlastname;
$customerObj->PreferredDeliveryMethod = 'Print';
$customerObj->BillWithParent = 'false';
if($client->active == '')
{
$customerObj->Active = (bool)false;
}
else
{
$customerObj->Active = 'true';
}
$phoneObj = new IPPTelephoneNumber();
$phoneObj->FreeFormNumber = $client->contactphonenumber;
$emailObj = new IPPEmailAddress();
$emailObj->Address = $client->contactemail;
$addrObj = new IPPPhysicalAddress();
$addrObj->Line1 = $client->contactaddress;
$customerObj->PrimaryPhone = $phoneObj;
$customerObj->PrimaryEmailAddr = $emailObj;
$customerObj->BillAddr = $addrObj;
好的,我终于找到问题了。经过大量搜索,我在这里找到了一篇文章。
您需要将您的 sdk.config 文件修改为以下 XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<intuit>
<ipp>
<!--Json serialization not supported in PHP SDK v2.0.5 -->
<message>
<request serializationFormat="Xml" compressionFormat="None"/>
<response serializationFormat="Xml" compressionFormat="None"/>
</message>
<service>
<baseUrl qbd="https://sandbox-quickbooks.api.intuit.com/" qbo="https://sandbox-quickbooks.api.intuit.com/" ipp="https://appcenter.intuit.com/api/" />
</service>
<logger>
<!-- To enable/disable Request and Response log-->
<requestLog enableRequestResponseLogging="false" requestResponseLoggingDirectory="/IdsLogs" />
</logger>
</ipp>
</intuit>
</configuration>
我之前运行的代码是在生产环境中,如果您使用的是开发沙箱,您需要更改正确的引用。
希望此信息对某人有所帮助。
我正在使用 Quickbooks PHP SDK。
我目前正在尝试 运行 下面的命令:
$res = $dataService->Add($customerObj);
我知道命令现在正在抛出异常,但我不知道异常是什么或如何判断出了什么问题?
我该怎么做?
注意::我会自己弄清楚 customerObj 有什么问题以节省你们的时间,只需要弄清楚如何找出返回给我的错误是什么。
Update:: Its 异常错误,但不知道这是什么意思?
这里是代码的其余部分:
$requestValidator = new OAuthRequestValidator(
gdizDecrypt($qbkeys->oauthtoken),
gdizDecrypt($qbkeys->oauthtokensecret),
OAUTH_CONSUMER_KEY,
OAUTH_CONSUMER_SECRET
);
$serviceContext = new ServiceContext($qbkeys->realmid, $qbkeys->datasource, $requestValidator);
$dataService = new DataService($serviceContext);
$customerObj = new IPPCustomer();
$customerObj->GivenName = $client->contactfirstname.' '.$client->contactlastname;
$customerObj->FamilyName = $client->contactlastname;
$customerObj->DisplayName = $client->contactfirstname.' '.$client->contactlastname;
$customerObj->PreferredDeliveryMethod = 'Print';
$customerObj->BillWithParent = 'false';
if($client->active == '')
{
$customerObj->Active = (bool)false;
}
else
{
$customerObj->Active = 'true';
}
$phoneObj = new IPPTelephoneNumber();
$phoneObj->FreeFormNumber = $client->contactphonenumber;
$emailObj = new IPPEmailAddress();
$emailObj->Address = $client->contactemail;
$addrObj = new IPPPhysicalAddress();
$addrObj->Line1 = $client->contactaddress;
$customerObj->PrimaryPhone = $phoneObj;
$customerObj->PrimaryEmailAddr = $emailObj;
$customerObj->BillAddr = $addrObj;
好的,我终于找到问题了。经过大量搜索,我在这里找到了一篇文章。
您需要将您的 sdk.config 文件修改为以下 XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<intuit>
<ipp>
<!--Json serialization not supported in PHP SDK v2.0.5 -->
<message>
<request serializationFormat="Xml" compressionFormat="None"/>
<response serializationFormat="Xml" compressionFormat="None"/>
</message>
<service>
<baseUrl qbd="https://sandbox-quickbooks.api.intuit.com/" qbo="https://sandbox-quickbooks.api.intuit.com/" ipp="https://appcenter.intuit.com/api/" />
</service>
<logger>
<!-- To enable/disable Request and Response log-->
<requestLog enableRequestResponseLogging="false" requestResponseLoggingDirectory="/IdsLogs" />
</logger>
</ipp>
</intuit>
</configuration>
我之前运行的代码是在生产环境中,如果您使用的是开发沙箱,您需要更改正确的引用。
希望此信息对某人有所帮助。