亚马逊mws提交饲料

时间:2013-04-08 15:26:25

标签: curl amazon-mws

我正在尝试使用SubmitFeed操作更新数量。有任何人对此有经验吗?我收到的错误是:'必须存在Action或Operation查询参数',但我在查询字符串中有'Action = SubmitFeed'。

我已经编写了四个完美运行的其他函数(RequestReport,GetReportRequestList,GetReport和GetFeedSubmissionList)。我想我错过了一些cURL配置选项以便发布文件。

cURL选项:

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Content-MD5: '. $md5,
    'Transfer-Encoding: chunked',
)),
curl_setopt($ch, CURLINFO_HEADER_OUT => true);
curl_setopt($ch, CURLOPT_UPLOAD => true);
curl_setopt($ch, CURLOPT_PROTOCOLS => CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $url_parts));

有人可以帮忙吗?谢谢。

1 个答案:

答案 0 :(得分:0)

要进行SubmitFeed调用,您必须使用Content-Type: text/xml并将您的XML Feed用作CURLOPT_POSTFIELDS。您的其他选项字段必须进入网址,就好像这是GET

$ch = curl_init($url_with_fields);                   <-- change 1
curl_setopt($ch, CURLOPT_HTTPHEADER => array(
    'Content-Type: text/xml',                        <-- change 2
    'Content-MD5: '. $md5,
    'Transfer-Encoding: chunked',
)),
curl_setopt($ch, CURLINFO_HEADER_OUT => true);
curl_setopt($ch, CURLOPT_UPLOAD => true);
curl_setopt($ch, CURLOPT_PROTOCOLS => CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);      <-- change 3

请注意,这种类型的调用适用于RequestReport,GetReportRequestList,GetReport和&amp; GetFeedSubmissionList:在这些情况下只需将$ xmldata留空。