我指的是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>
我尝试了两个不同的访问密钥与同一个用户并注册了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);
}
我不确定我做错了什么。
答案 0 :(得分:5)