目标:我们尝试使用 QuickBooks Web 连接器从 QuickBooks Desktop for Windows 中每小时获取一次所有交易。
状态:QuickBooks Web 连接器使用配置的 qwc 文件成功运行。
问题:QuickBooks Web 连接器返回绿色消息“不需要数据交换”。我期望事务存储在 log.txt 中。下面是我的代码。我怀疑这是一个排队问题?我希望所有排队都在这个文件中,该文件在 QBWC 中每小时运行一次以获取所有事务。您能提供的任何帮助将不胜感激。
//web_connector.php - called every 60 min from QBWC
$map = array(
'*' => array( '_quickbooks_get_transactions', '_quickbooks_get_transactions_response' ),
);
$log_level = QUICKBOOKS_LOG_DEVELOP;
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
$handler_options = array(
'deny_concurrent_logins' => false,
'deny_reallyfast_logins' => false,
);
$dsn = 'mysqli://'.$dbUser.':'.$dbPass.'@localhost/'.$dbName;
if (!QuickBooks_Utilities::initialized($dsn))
{
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
//Create a new server and tell it to handle the requests
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks,
$log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options,
$driver_options, $callback_options);
$response = $Server->handle(true, true);
function _quickbooks_get_transactions($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
//I want to get all transactions from this QuickBooks file and then insert into a database table on my cloud server.
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<TransactionQuery requestID="' . $requestID . '">
</TransactionQuery>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_get_transactions_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
//I want to get all transactions from this QuickBooks file and then insert into a database table on my cloud server.
//store returned data in text file for testing
$fp = fopen('log.txt', 'a+');
fwrite($fp, $xml);
fclose($fp);
return;
}