当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Amazon MWS GetReport Invalid Date Range

问题描述:

I keep getting an invalid date range response from my request. I am not sure what is wrong. I have all the parameters and a valid 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);

The output I get back is Invalid Date Range

网友答案:

Does it work through Amazon's scratchpad? I just tried a GetReport operation and it came back just fine. Of course no date range is needed because you're trying to get back a specific report by id. I usually go to the scratchpad as a quick and easy way to get info from MWS.

My POST looks like this:

网友答案:

Well after contacting Amazon this is what is came down to. When I requested the report using the RequestReport Action I supplied an invalid Date Range. So the report itself return Invalid Date Range as the content of the report.

分享给朋友:
您可能感兴趣的文章:
随机阅读: