我们计算的请求签名与您提供的签名不匹配。 - AWS中的错误

I have following code :

$method = "GET";
$host = "payments-sandbox.amazon.com";
$uri = "/cba/api/purchasecontract/";
$private_key='PRIVATE_KEY';
$time = date('c');

$params = array(
    'AWSAccessKeyId' => $private_key,
    'Action' => "CreatePurchaseContract",
    'SignatureMethod' => "HmacSHA256",
    'SignatureVersion' => "2",
    'Timestamp' => $time);

uksort($params, 'strcmp');
$canonicalized_query = array();
foreach ($params as $param => $value) {
    $param = str_replace("%7E", "~", rawurlencode($param));
    $value = str_replace("%7E", "~", rawurlencode($value));
    $canonicalized_query[] = $param . "=" . $value;
}
$canonicalized_query = implode("&", $canonicalized_query);
$string_to_sign = $method . "
" . $host . "
" . $uri . "
" . $canonicalized_query;
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, True));
$signature = str_replace("%7E", "~", rawurlencode($signature));

echo $url = "https://payments-sandbox.amazon.com/cba/api/purchasecontract/"
 . "?Action=CreatePurchaseContract"
 . "&SignatureMethod=HmacSHA256"
 . "&AWSAccessKeyId=$private_key"
 . "&Signature=".$signature
 . "&SignatureVersion=2"
 . "&Timestamp=" . $time;

But when i open url in new tab it's return following XML :

<ErrorResponse>
    <Error>
        <Type>Sender</Type>
        <Code>SignatureDoesNotMatch</Code>
        <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>
    </Error>
    <RequestId>01a5de72-6e3f-11e4-85b3-9119f1b849cd</RequestId>
</ErrorResponse>

And it's give 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. error message when open $url link in new tab.

I dont know what's problem in creating signature??

[UPDATE]

I have try cUrl to fetch data :

$ch = curl_init();

$options = array(CURLOPT_URL => $url);
curl_setopt_array($ch, $options);
$data = curl_exec($ch);

if(!$data){
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
curl_close($ch);
print_r($data);

But it's give me Error: "SSL certificate problem: unable to get local issuer certificate" - Code: 60. So what i do to fetch data from payments-sandbox.amazon.com

I got the same error when I tried to add my credentials with the eb init command in EB CLIx3.

It turned out I had mistyped my credentials every single time. I switched over to console for Windows where I could copy/paste my credentials. Now everything went without a hitch.

So copy/past credentials is my suggestion. If that doesn't work, you might want to create a new access key for a user with admin privileges. You can do that at the IAM section. Then try to copy past again.