I’m spending many hours to try to solve this problem. I must create a ListOrders, but I always get this error:
[B]Sender SignatureDoesNotMatch 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.
I think that either signature and other fields arrive to Amazon server, because I tested all here:
[URL=”https://mws-eu.amazonservices.com/scratchpad/index.html”]https://mws-eu.amazonservices.com/scratchpad/index.html
[code=php]function call_amazon(){
$campi[“AWSAccessKeyId”] = rawurlencode($this->AWSAccessKeyId);
$campi[“Action”] = ‘ListOrders’;
$campi[“MarketplaceId.Id.1”] = rawurlencode($this->marketplaceid);
$campi[“SellerId”] = rawurlencode($this->Merchant);
$campi[“SignatureVersion”] = rawurlencode($this->SignatureVersion);
$campi[“SignatureMethod”] = rawurlencode($this->SignatureMethod);
$campi[“LastUpdatedAfter”] = $this->LastUpdatedAfter;
$campi[“Timestamp”] = gmdate(‘Y-m-d’).”T”.gmdate(‘H:i:s’).”Z”;
$campi[“Version”] = rawurlencode(“2013-09-01”);
$signature = $this->crea_signature($campi,$campi[“Timestamp”]);
$campi[‘Signature’] = urlencode($signature);
ksort($campi);
$fields_string = ”;
foreach($campi as $key=>$value) {
$fields_string .= $key.’=’.$value.’&’;
}
rtrim($fields_string, ‘&’);
// Elimina la & in fondo alla query string
$lung = strlen($fields_string) – 1;
$fields_string = substr($fields_string, 0,$lung);
$ch = curl_init($this->endpoint);
curl_setopt($ch,CURLOPT_POST, count($campi));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$output = curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
return simplexml_load_string($output);
}
function crea_signature($campi,$ts){
$stringa = ‘POST’;
$stringa .= “n”;
$stringa .= “mws-eu.amazonservices.com”;
$stringa .= “n”;
$stringa .= urlencode(“/Orders/2013-09-01”);
$stringa .= “n”;
$stringa .= “AWSAccessKeyId=”.$campi[“AWSAccessKeyId”];
$stringa .= “&Action=”.$campi[“Action”];
$stringa .= “&LastUpdatedAfter=”.$campi[“LastUpdatedAfter”];
$stringa .= “&MarketplaceId.Id.1=”.$campi[“MarketplaceId.Id.1”];
$stringa .= “&SellerId=”.$campi[“SellerId”];
$stringa .= “&SignatureMethod=”.$campi[“SignatureMethod”];
$stringa .= “&SignatureVersion=”.$campi[“SignatureVersion”];
$stringa .= “&Timestamp=”.$ts;
$stringa .= “&Version=”.$campi[“Version”];
$s = hash_hmac(‘sha256’, str_replace(‘ ‘, ”, $stringa), $this->secret, true);
$sig = base64_encode($s);
return $sig;
}
All the values of the given fields are correct. Could anyone help me, please? Thanks.