亚马逊MWS GetReport错误

时间:2015-10-18 04:05:35

标签: php amazon-mws

我试图通过_GET_WEBSTORE_PRODUCT_CATALOG_ ReportType获取有关产品目录的信息。我成功地提交了报告请求,甚至它已被处理,甚至处理状态都已完成,并且还收集了生成的ID。但是当我尝试通过Action:GetReport获取报告时,即使提到了市场,它也不会发送市场。下面是代码示例,我没有使用任何PHP客户端库....

代码示例

<?php

require 'config.php';    
$param = array(
    'AWSAccessKeyId'=> AWS_KEY,
    'Action'=>'GetReport',

    'ReportId'=>'513798174016724',
    'Merchant'=> MERCHANT_ID,
    'SignatureMethod' => "HmacSHA256",
    'SignatureVersion'=> "2",
    'Timestamp'=> gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()),
    'Version' => "2009-01-01",
    'Marketplace'=>MARKETPLACE
);
$secret = AWS_SECRET_ACCESS_KEY;
$url = array();
foreach ($param as $key => $val) {
    $key = str_replace("%7E", "~", rawurlencode($key));
    $val = str_replace("%7E", "~", rawurlencode($val));
    $url[] = "{$key}={$val}";
}    
sort($url);
$arr   = implode('&', $url);
$sign  = 'POST' . "\n";
$sign .= 'mws.amazonservices.com' . "\n";
$sign .= '/' . "\n";
$sign .= $arr;    
$signature = hash_hmac("sha256", $sign, $secret, true);
$signature = urlencode(base64_encode($signature));    
$link  = "https://mws.amazonservices.com/?";
$link .= $arr . "&Signature=" . $signature;
$curl = curl_init();
curl_setopt_array($curl, array(

    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $link,
    CURLOPT_POST => 1,

    )
);  

$resp1 = curl_exec($curl);    
curl_close($curl);    
print_r($resp1);

错误示例 请指明需要报告的市场。 有什么我想念的吗?或者我输入错误的地方...... 感谢您提前解决..

1 个答案:

答案 0 :(得分:0)

尝试更改为

$request = new MarketplaceWebService_Model_RequestReportRequest();

$marketplaceIdArray = array("Id" => array($marketplace_id));
$request->setMarketplaceIdList($marketplaceIdArray);
$request->setMerchant($merchant_id);
$request->setReportType($this->report_type);