dongzaliang4492 2015-06-09 10:25
浏览 34

too long

I'm having problems submitting a feed to Amazon MWS. I keep receiving the following error: "Invalid query string provided - Keys may not contain <"

This is my code:

$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 is formed on-the-fly and comes in the form:

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=***

(which works fine with other calls to Reports or to Orders)

$this->xml is kept as a "TEXT" field in the MySQL db; this is a sample XML (I added lines to make it readable):

<?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>

I seem to review every single relevant link on the internet and cannot find the answer.

Maybe someone can give me a hint what may go wrong in the above code?

Thanks.

  • 写回答

1条回答 默认 最新

  • dtmbc1606 2015-06-09 11:52
    关注

    Found the solutions myself (after digging more that a day):

    1) Content-MD5 must be calculated in the following way:

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

    (thanks to this answer: https://sellercentral.amazon.com/forums/message.jspa?messageID=2767745)

    2) passing header parameters to cUrl must be one-time operation, that is - all headers have to be passed as an array.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用