我将consolibyte Keith Palmer的PHP SDK用于带有Web连接器的QuickBooks Desktop。 以下是销售收货单请求的代码。此代码一定出了什么问题?我打印了xml。它正确地打印。然后可能是该错误的原因-“ QuickBooks在解析提供的XML时发现错误”文本流,请帮帮我................. ......
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesReceiptModRq requestID = "'.$requestID.'">
<SalesReceiptMod>
<TxnID>'.$row_invoice['quickbooks_txnID'].'</TxnID>
<EditSequence>'.$row_invoice['edit_sequence'].'</EditSequence>
<CustomerRef>
<ListID>'.$row_customer['quickbooks_listid'].'</ListID>
</CustomerRef>
<TxnDate>'.$row_invoice['invoice_date'].'</TxnDate>
<RefNumber>601</RefNumber>
<BillAddress>
<Addr1>'.$row_customer['address_1'].'</Addr1>
</BillAddress>';
while($row_invoice_details = mysqli_fetch_array($sql_sale_invoice_details))
{
$row_item = mysqli_fetch_array(mysqli_query($con,"SELECT quickbooks_listid FROM item WHERE item_id =".$row_invoice_details['item_id']));
$xml .= '
<SalesReceiptLineMod>
<TxnLineID>'.$row_invoice_details['quickbooks_txnLineId'].'</TxnLineID>
<ItemRef>
<ListID>'.$row_item['quickbooks_listid'].'</ListID>
</ItemRef>
<Desc>'.$row_invoice_details['description'].'</Desc>
<Quantity>'.$row_invoice_details['quantity'].'</Quantity>
<Rate>'.$row_invoice_details['price'].'</Rate>';
/////////check if tax is applied or not////////////////
if($row_invoice['sales_tax_percent']!=0)
{
$xml .= ' <SalesTaxCodeRef>
<FullName>tax</FullName>
</SalesTaxCodeRef>';
}
else
{
$xml .= '<SalesTaxCodeRef>
<FullName>non</FullName>
</SalesTaxCodeRef>';
}
///////////////////////////////////////
$xml.='</SalesReceiptLineMod>';
}
$xml .= '</SalesReceiptMod>
</SalesReceiptModRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
下面显示的是xml
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesReceiptModRq requestID = "1">
<SalesReceiptMod>
<TxnID>279-1574097843</TxnID>
<EditSequence>1574097843</EditSequence>
<CustomerRef>
<ListID>80000030-1573831750</ListID>
</CustomerRef>
<TxnDate>2019-11-18</TxnDate>
<RefNumber>601</RefNumber>
<BillAddress>
<Addr1>kothrud1234564789</Addr1>
</BillAddress>
<SalesReceiptLineMod>
<TxnLineID>27B-1574097843</TxnLineID>
<ItemRef>
<ListID>8000004A-1574094120</ListID>
</ItemRef>
<Desc>100 meter pipe</Desc>
<Quantity>1</Quantity>
<Rate>300</Rate> <SalesTaxCodeRef>
<FullName>tax</FullName>
</SalesTaxCodeRef></SalesReceiptLineMod>
<SalesReceiptLineMod>
<TxnLineID>27C-1574097843</TxnLineID>
<ItemRef>
<ListID>8000004B-1574094123</ListID>
</ItemRef>
<Desc>200 meters pipe</Desc>
<Quantity>1</Quantity>
<Rate>400</Rate> <SalesTaxCodeRef>
<FullName>tax</FullName>
</SalesTaxCodeRef></SalesReceiptLineMod>
<SalesReceiptLineMod>
<TxnLineID>27D-1574097843</TxnLineID>
<ItemRef>
<ListID>8000004C-1574094242</ListID>
</ItemRef>
<Desc>test desc</Desc>
<Quantity>1</Quantity>
<Rate>200</Rate> <SalesTaxCodeRef>
<FullName>tax</FullName>
</SalesTaxCodeRef></SalesReceiptLineMod></SalesReceiptMod>
</SalesReceiptModRq>
</QBXMLMsgsRq>
</QBXML>
答案 0 :(得分:0)
您的问题将由XML不接受的字符引起。
首先,我寻找诸如&
之类的符号,这些符号需要经过HTML编码为&
等。
您的破折号似乎导致了您的问题。
PHP快速手册似乎具有“广播”功能,用于处理超出可接受范围的字符。
这是仓库中的一个例子。希望这可以帮助!作为第一个测试,请尝试从生成的XML中删除非ASCII字符(尝试破折号-
),并查看其是否成功处理。
https://github.com/consolibyte/quickbooks-php/blob/master/docs/qbxml/example_qbxml_cast.php