我指的是Alexa Top Sites Developer Guide并使用their sample codes, both PHP and Ruby 。我收到以下 SignatureDoesNotMatch
错误:
<?xml version="1.0"?>
<Response><Errors><Error><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></Errors><RequestID>28c6b028-c4b6-66a2-f5d8-70d8dc21b8f8</RequestID>
</Response>
我使用同一用户尝试了两个不同的访问 key 并注册了 Alexa Web 信息服务,但没有成功。我在 Mac OS 10.9 和 10.10 上都尝试过这些脚本,我的时间设置设置为自动更新。
在 PHP 代码中,这是生成签名的部分:
/**
* Generates a signature per RFC 2104
*
* @param String $queryParams query parameters to use in creating signature
* @return String signature
*/
protected function generateSignature($queryParams) {
$sign = "GET\n" . strtolower(self::$ServiceHost) . "\n/\n". $queryParams;
echo "String to sign: \n" . $sign . "\n\n";
$sig = base64_encode(hash_hmac('sha256', $sign, $this->secretAccessKey, true));
return rawurlencode($sig);
}
我不知道我做错了什么。
最佳答案
我明白了。 AWS 根用户可以发出请求,但我创建的 IAM 用户不能发出请求。我猜 root 用户可以访问 Alexa 服务,但不能访问 IAM 用户。
关于php - `SignatureDoesNotMatch` 来自 Alexa Top Sites 服务的 AWS 的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27238694/