we are trying to access the Amazon MWS Api but we just can't get it to work and we don't know why. This is what we have tried so far:
require_once('.config.inc.php');
$base_url = "http://ift.tt/1FCiwnK";
$method = "POST";
$host = "mws.amazonservices.de";
$uri = "/Products/2011-10-01";
$params = array(
'AWSAccessKeyId' => <our Key>,
'Action' => "GetLowestOfferListingsForASIN",
'SellerId' => <our ID>,
'SignatureMethod' => "HmacSHA256",
'SignatureVersion' => "2",
'Timestamp'=> gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()), //tried this with time()+7200 since our server is 2 hours back but we also accessed mws to get the time used there
'Version'=> "2011-10-01",
'MarketplaceId' => <our MpID>,
'ItemCondition' => 'new',
'ASINList.ASIN.1' => B00NN8LSXY );
// 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 = "POST\nmws.amazonservices.de\n/Products/2011-10-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 = "http://ift.tt/1FCiwnK" . '?' . $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);
//$parsed_xml = simplexml_load_string($response);
echo $response;
//return ($parsed_xml);
in the .config.inc.php file we added all the Keys & IDs +
define('APPLICATION_NAME', '<our Firm>');
define('APPLICATION_VERSION', '1.0');
before we did all that we checked everything in MWS-Scratchpad but everything seems to be working there (on mws.amazon.de).
But we still get the SignatureDoesNotMatch Errorcode
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>
or this Errorcode:
<Message>Request signature is for too far in the future. Timestamp date: 2015-05-23T04:54:38.000Z. Currently, 10 percent of requests that are more than 15 minutes in the future will be rejected.</Message>
Hope someone can help we went through every other post and developer-guide about this - nothing seems to help
Not sure if you've ever solved this. but its because amazon (the bellends) set their server to GMT-0.
RépondreSupprimerSo, if you're out by more than 15 mins, they tell you you're too far in the future.
Excellent for those in the UK who find that it works for half the year and then stops working as soon as BST kicks in.