Goal: We are attempting to get all transactions once an hour out of QuickBooks Desktop for Windows using QuickBooks Web Connector.
Status: QuickBooks Web Connector runs successfully with the configured qwc file.
Issue: QuickBooks Web Connector returns a green message 'No Data Exchange Required'. I am expecting transactions to be stored in log.txt. Below is my code. I suspect this is a queing issue?. I would like all queing to be in this file that runs every hour in QBWC to get all transactions. Any assistance you can provide would be greatly appreciated.
//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;
}
That message means exactly what it says:
The Web Connector and this framework work using a 'queue' concept. Once the queue is empty, there's nothing else to do, and you'll get that message. If you add something to the queue, then it will process those items until there's nothing left to do, and then you'll get the “No Data Exchange…” message again.
You haven't added anything to the queue.
You could do this with a cron job, or by registering a function that runs whenever the Web Connector connects, and immediately stuffs something in the queue. e.g.:
You can see an extended example of this here:
Some other things you may want to take away from the example:
<?qbxml version="2.0"?>)