Amazon MWS SubmitFeed错误:键可能不包含<


Amazon MWS SubmitFeed error: Keys may not contain &lt;

我在向Amazon MWS提交提要时遇到问题。我一直收到以下错误:" Invalid query string provided - Keys may not contain &lt; "

这是我的代码:

$apicall = $this->build_url($function, $params);
$ch = curl_init($apicall);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
if ($this->xml) {
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, (string)$this->xml);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-MD5: " . base64_encode(md5($this->xml))));
}
else {
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
$info = print_r(curl_getinfo($ch), true);
curl_close($ch);

$apicall是动态生成的,其形式为:

https://mws.amazonservices.com/Feeds/2009-01-01?ASINList.ASIN.1=B00C5XBAOA&AWSAccessKeyId=***&Action=SubmitFeed&FeedType=_POST_PRODUCT_PRICING_DATA_&MWSAuthToken=***&SellerId=***&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2015-06-09T09%3A58%3A01.000Z&Version=2009-01-01&Signature=***

(与其他调用报告或订单的工作良好)

$this->xml在MySQL数据库中保持为"TEXT"字段;这是一个示例XML(我添加了一些行以使其可读):

<?xml version="1.0"?>
<AmazonEnvelope xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="amzn-envelope.xsd">
    <Header>
        <DocumentVersion>1.01</DocumentVersion>
        <MerchantIdentifier>***</MerchantIdentifier>
    </Header>
    <MessageType>Price</MessageType>
    <Message>
        <MessageID>1</MessageID>
        <OperationType>Update</OperationType>
        <Price>
            <SKU>***</SKU>
            <StandardPrice currency="USD">33.5</StandardPrice>
        </Price>
    </Message>
</AmazonEnvelope>

我似乎在网上浏览了每一个相关的链接,却找不到答案。

也许有人可以给我一个提示,上面的代码可能会出错?

谢谢。

我自己找到了解决方案(经过一天多的挖掘):

1) Content-MD5必须按以下方式计算:

base64_encode(md5($this->xml, **true**));

(感谢这个答案:https://sellercentral.amazon.com/forums/message.jspa?messageID=2767745)

2)向cUrl传递标头参数必须是一次性操作,也就是说-所有的标头必须以数组的形式传递。