我们在web应用程序中使用Keith /Consoli字节解决方案的优秀PHP QuickBooks框架与QuickBooks桌面版本通过QuickBooks网络连接器进行通信。我们在代码中使用QuickBooks_Server和QuickBooks_Queue,如下所示:
$this->myQBQueue = new QuickBooks_Queue($this->myDSN);
$mappedFunctions = array(
QUICKBOOKS_ADD_CUSTOMER,
QUICKBOOKS_ADD_SALESORDER,
QUICKBOOKS_ADD_SALESRECEIPT,
QUICKBOOKS_QUERY_CUSTOMER,
);
$map = array();
foreach($mappedFunctions as $function) {
$map[$function] = array(
array($this,"quickbooks{$function}Request"),
array($this,"quickbooks{$function}Response"),
);
}
$errmap = array('*' => array($this,'quickbooksErrorHandler'));
$hooks = array(
QUICKBOOKS_HANDLERS_HOOK_LOGINFAILURE => array(
array($this,'quickbooksLoginFailureHook')
),
QUICKBOOKS_HANDLERS_HOOK_LOGINSUCCESS => array(
array($this,'quickbooksLoginSuccessHook')
)
);
$soap_options = array();
$handler_options = array();
$driver_options = array();
$callback_options = array();
$this->myQBServer = new QuickBooks_Server($this->myDSN, $map, $errmap, $hooks, QUICKBOOKS_LOG_NORMAL, QUICKBOOKS_SOAPCLIENT_BUILTIN, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);我们现在有一位客户要求我们添加对QuickBooks在线的支持。我们仍然可以使用Keith的QuickBooks_Server在线框架和QuickBooks_Queue,还是必须为QuickBooks online部分编写新代码?
发布于 2012-10-17 23:06:32
您可以重用队列内容,但是框架本身并不支持它--您肯定可以很容易地破解它。
您也肯定能够重用qbXML的大部分(但不是全部)。
QuickBooks Online确实支持qbXML接口(尽管它不是很好- Intuit公开表示,他们可能在未来一年左右就不再支持它,并且不再向它添加功能)。您应该知道,在不久的将来,您很可能会开始考虑转向Intuit /IDS-,尤其是,如果您是一个拥有大量QuickBooks在线客户的SaaS应用程序。
您可以在这里找到qbXML QuickBooks在线文档:http://developer.intuit.com/qbsdk-current/common/newosr/index.html (确保勾选"OE“复选框,取消选中"US”复选框)
有几件事让很多人在QuickBooks在线上受到了伤害:
如果您查看包含在QuickBooks PHP DevKit库代码中的docs/example_DevKit_edition.php(或docs/example_DevKit_edition.php)文件,您将看到它是如何工作的。基本上,您只是通过HTTPS向Intuit的服务器发送直接的qbXML请求,而不是将其封装在SOAP中,等待获取。
尽管如此,如果您真的想继续使用队列,您可以像往常一样排队,只需设置一个脚本,比如在cron作业上运行这样的脚本:
(警告-完全未经测试的代码,您将不得不测试和调试)
<?php
// Do some setup stuff here as shown in the example...
$res = mysql_query("SELECT * FROM quickbooks_queue WHERE qb_username = 'the username' AND qb_status = 'q'");
while ($arr = mysql_fetch_array($res))
{
$request_function = $map[$arr['qb_action']][0];
$response_function = $map[$arr['qb_action']][1];
$requestID = null; // not relevant for QBO
$user = 'the username';
$ID = $arr['ident'];
$extra = null;
if($arr['extra']) $extra = unserialize($arr['extra']);
$err = null;
$last_action_time = null;
$last_actionident_time = null;
$version = '6.0'; // QBO only supports 6.0
$locale = 'US'; // QBO only supports US
$qbxml = $request_function($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale);
$xml = $API->qbxml($qbxml);
$idents = _extractIdentifiers($xml); // You can find this function in QuickBooks/Handlers.php and pull it into your app as a function instead of a method
$response_function($requestID, $user, $action, $ID, $extra, $err, $last_action_time, $last_actionident_time, $xml, $idents);
}https://stackoverflow.com/questions/12906396
复制相似问题