我一直收到来自我的请求的无效日期范围回复。我不确定是什么问题。我有所有参数和有效的ReportID。
$params = array(
'AWSAccessKeyId' => AWS_ACCESS_KEY_ID,
'Action' => "GetReport",
'SellerId' => MERCHANT_ID,
'SignatureMethod' => "HmacSHA256",
'SignatureVersion' => "2",
'Timestamp' => $timestamp,
'Version'=> "2009-01-01",
'Marketplace' => MARKETPLACE_ID,
'ReportId' => $reportID
);
// Sort the URL parameters
$url_parts = array();
foreach(array_keys($params) as $key)
$url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key]));
sort($url_parts);
// Construct the string to sign
$url_string = implode("&", $url_parts);
$string_to_sign = "GET\nmws.amazonservices.com\n/Reports/2009-01-01\n" . $url_string;
// Sign the request
$signature = hash_hmac("sha256", $string_to_sign, AWS_SECRET_ACCESS_KEY, TRUE);
// Base64 encode the signature and make it URL safe
$signature = urlencode(base64_encode($signature));
$url = "https://mws.amazonservices.com/Reports/2009-01-01" . '?' . $url_string . "&Signature=" . $signature;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
print_r($response);
我得到的输出是无效日期范围
答案 0 :(得分:0)
它是否适用于亚马逊的scratchpad?我刚刚尝试了一个GetReport操作,它恢复得很好。当然,不需要日期范围,因为您尝试按ID返回特定报告。我通常会使用暂存器作为从MWS获取信息的快捷方式。
我的POST看起来像这样:
答案 1 :(得分:0)
在与亚马逊联系之后,这是归结为什么。当我使用RequestReport Action请求报告时,我提供了无效的日期范围。因此报告本身会返回无效日期范围作为报告的内容。