When I run this code, I get a SignatureDoesNotMatch error 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.
<?php
$param = array();
$param['AWSAccessKeyId'] = 'AWSAccessKeyId';
$param['Action'] = 'ListOrders';
$param['MWSAuthToken'] = 'MWSAuthToken';
$param['MarketplaceId'] = 'A21TJRUUN4KGV';
$param['FulfillmentChannel.Channel.1'] = 'MFN';
$param['PaymentMethod.Method.1'] = 'COD';
$param['OrderStatus.Status.1'] = 'Pending';
$param['OrderStatus.Status.2'] = 'PendingAvailability';
$param['SellerId'] = 'AGNFZGZRZBUP1';
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['CreatedAfter'] = "2017-09-01T13:41:49Z";
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2013-09-01';
$secret = 'secret key';
$url = array();
foreach ($param as $key => $val) {
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = $key . "=" . $val;
}
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.in' . "\n";
$sign .= '/Orders/2013-09-01' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.in/Orders/2013-09-01?";
$link .= $arr;
$link .= "&Signature=" . $signature;
echo($link); //for debugging - you can paste this into a browser and see if it loads.
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo "<pre>";
print_r($response);
print_r($info);
?>