我正在尝试使用consoliBYTE PHP libray从Quickbook桌面获取所有员工,但它生成错误“0x80040400:QuickBooks在解析提供的XML文本流时发现错误。
$attr_iteratorID = '';
$attr_iterator = ' iterator="Start" ';
if (empty($extra['iteratorID']))
{
// This is the first request in a new batch
$last = $this->_quickbooks_get_last_run($user, $action);
$this->_quickbooks_set_last_run($user, $action);
// Set the current run to $last
$this->_quickbooks_set_current_run($user, $action, $last);
}
else
{
// This is a continuation of a batch
$attr_iteratorID = ' iteratorID="' . $extra['iteratorID'] . '" ';
$attr_iterator = ' iterator="Continue" ';
$last = $this->_quickbooks_get_current_run($user, $action);
}
// Build the request
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="' . $version . '"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<EmployeeQueryRq metaData="ENUMTYPE" requestID="' . $requestID . '">
</EmployeeQueryRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
如果我从XML中删除迭代器,那么它工作正常,我得到一个新问题,我不能让所有员工,它显示错误,无效的ResponsXML错误 “QBWC1042:ReceiveResponseXML失败”。
$Parser = new QuickBooks_XML_Parser($xml);
//$this->db->insert('save_response', $arr);
if ($Doc = $Parser->parse($errnum, $errmsg))
{
$Root = $Doc->getRoot();
$List = $Root->getChildAt('QBXML/QBXMLMsgsRs/EmployeeQueryRs');
foreach ($List->children() as $Customer)
{
$arr = array(
'listid' => $Customer->getChildDataAt('EmployeeRet ListID'),
'timecreated' => $Customer->getChildDataAt('EmployeeRet TimeCreated'),
'timemodified' => $Customer->getChildDataAt('EmployeeRet TimeModified'),
'editsequence' => $Customer->getChildDataAt('EmployeeRet EditSequence'),
'name' => $Customer->getChildDataAt('EmployeeRet Name'),
'isactive' => $Customer->getChildDataAt('EmployeeRet IsActive'),
'salutation' => $Customer->getChildDataAt('EmployeeRet salutation'),
'firstname' => $Customer->getChildDataAt('EmployeeRet FirstName'),
'middlename' => $Customer->getChildDataAt('EmployeeRet MiddleName'),
'lastname' => $Customer->getChildDataAt('EmployeeRet LastName'),
'employeeaddress' =>$Customer->getChildDataAt('EmployeeRet EmployeeAddress Addr1'),
'city' =>$Customer->getChildDataAt('EmployeeRet EmployeeAddress City'),
'state' =>$Customer->getChildDataAt('EmployeeRet EmployeeAddress State'),
'postalcode' =>$Customer->getChildDataAt('EmployeeRet EmployeeAddress PostalCode'),
'employeetype' => $Customer->getChildDataAt('EmployeeRet EmployeeType'),
'birthdate' => $Customer->getChildDataAt('EmployeeRet BirthDate'),
'hireddate' => $Customer->getChildDataAt('EmployeeRet HiredDate'),
);
QuickBooks_Utilities::log(QB_QUICKBOOKS_DSN, 'Importing employee ' . $arr['name'] . ': ' . print_r($arr, true));
$result = $this->db->insert('quickbook_employee', $arr);
}
}
return true;
任何人都可以让我知道我错在哪里。
提前致谢
答案 0 :(得分:0)
如果您参考文档:
您会注意到EmployeeQuery
不支持迭代器。所以,删除迭代器。
此错误:
QBWC1042: ReceiveResponseXML failed
99.9%的时间意味着您的代码中存在PHP或SQL错误。具体来说,在您的响应处理函数中。
不幸的是,您没有将足够的代码发布到我们实际可以测试的地方,因此没有人能够告诉您实际的错误是什么。
您是否检查过PHP错误日志?