Php Quickbooks异常和错误(如何判断它们是什么?)
我正在使用Quickbooks PHP SDK 我当前正在尝试运行以下命令:Php Quickbooks异常和错误(如何判断它们是什么?),php,quickbooks,quickbooks-online,Php,Quickbooks,Quickbooks Online,我正在使用Quickbooks PHP SDK 我当前正在尝试运行以下命令: $res = $dataService->Add($customerObj); 我知道命令现在正在抛出异常,但我无法判断异常是什么,或者如何判断出错的原因 我该怎么做 注意:我会自己找出customerObj的错误,以节省你们的时间,只需要找出如何找出返回给我的错误 更新::这是一个Ids异常错误,但不知道这意味着什么 根据要求,以下是代码的其余部分: $requestValidator = new OAuth
$res = $dataService->Add($customerObj);
我知道命令现在正在抛出异常,但我无法判断异常是什么,或者如何判断出错的原因
我该怎么做
注意:我会自己找出customerObj的错误,以节省你们的时间,只需要找出如何找出返回给我的错误
更新::这是一个Ids异常错误,但不知道这意味着什么
根据要求,以下是代码的其余部分:
$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>
我以前使用的代码是在生产环境中使用的,如果您使用的是开发沙盒,那么您需要更改正确的引用
希望这些信息对某人有所帮助。你怎么知道它在扔?找出返回给我的错误是什么-它说了什么?我将它包装在一个try{}catch{}语句中,catch正在触发,消息/堆栈跟踪是什么?它有点长,但这就是它,{command:Failed,message:Quickbooks API Error occurrent.,exception:IdsException对象\n\n[消息:protected]=>2015-09-03 13:53:37-\/home\/betapoolserviceu\/public\u html\/vendor\/quickbooks\/DataService\/DataService.php-340-CheckNullResponseAndThrowException-Response Null或空\n[字符串:异常:私有]=>\n[代码:受保护]=>0\n[文件:受保护]=>\/home\/betapoolserviceu\/public\u html\/vendor\/quickbooks\/Core\/coreheloper.php\n[line:protected]=>95\n[trace:…etcIt现在是一个IdsException对象,当我使用print\u re打印出e时,true