您正在使用来自 Intuit 的未发布代码,但实际上无法正常工作 - 您正在使用的代码已损坏。
不要使用它,而是使用GitHub 上提供的QuickBooks PHP DevKit 。它是开源的并且得到很好的支持,并且可以与 OAuth 和 v3 一起正常工作。
您可以按照QuickBooks PHP IPP v3 快速入门指南开始。您将经历与上述类似的过程,您将在配置中找到您自己的 OAuth 令牌/秘密和应用程序令牌,然后您将能够连接到 QuickBooks。
从那里,您会发现几个示例脚本 - 您添加客户的代码最终看起来像这样(来自 GitHub 存储库的示例:https ://github.com/consolibyte/quickbooks-php/blob/master/docs/example_app_ipp_v3 /example_customer_add.php):
<?php
// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);
// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
// Print the credentials we're using
//print_r($creds);
// This is our current realm
$realm = $creds['qb_realm'];
// Load the OAuth information from the database
if ($Context = $IPP->context())
{
// Set the IPP version to v3
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Mr');
$Customer->setGivenName('Keith');
$Customer->setMiddleName('R');
$Customer->setFamilyName('Palmer');
$Customer->setDisplayName('Keith R Palmer Jr ' . mt_rand(0, 1000));
if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . ']');
}
else
{
print($CustomerService->lastError($Context));
}
/*
print('<br><br><br><br>');
print("\n\n\n\n\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');
print("\n\n\n\n\n\n\n\n\n");
*/
}
else
{
die('Unable to load a context...?');
}
?>