Quickbooks Exptions&错误(如何判断它们是什么?)

时间:2015-09-03 14:22:31

标签: php quickbooks quickbooks-online

我正在使用Quickbooks PHP SDK。

我目前正在尝试运行以下命令:

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

1 个答案:

答案 0 :(得分:0)

好的,我终于找到了问题所在。经过多次狩猎,我在这里找到了一篇文章。

https://intuitdeveloper.lc.intuit.com/questions/1016393-checknullresponseandthrowexception-response-null-or-empty

您需要将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>

我之前使用过的代码是生产的,如果您使用的是开发沙箱,则需要更改正确的引用。

希望这些信息有助于某人。