我有一个API文档。我在创建签名请求时遇到问题。我有如何创建签名的以下过程。有人可以帮助我从下面的步骤一个例子:使用php生成API调用签名
生成签名创建签名
Create the canonical zed query string that you need later in this procedure:
Sort the UTF-8 query string components by parameter name with natural byte ordering. The parameters can come from the GET URI or from the POST body (when Content-Type is application/x-www-form-urlencoded).
URL encode the parameter name and values
Concatinate name and values to a single string (eg. var1value1var2value2)
Calculate an RFC 2104-compliant HMAC with the string you just created, your API Access Key as the key, and SHA1 as the hash algorithm.
Make the resulting value base64 encoded.
Use the Resulting value as the value of the Signature request parameter
编辑:
这里是文档的输出样本:
https://domain.com/api.php?action=checkDomain&version=20090622&keyId=123456 & name = glo0000w.com & signature = fvatTFVwRNF1cyH%2Fj%2Flaig8QytY%3D
下面是我试图这样做,但没有奏效
<?php
$sig = urlencode('actioncheckDomainversion20090622keyId123456nameglo0000w.com');
$sig = hash_hmac('sha1', $sig, '123456');
$sig = base64_encode($sig);
?>
有人可以帮我实现用PHP生成签名的程序?谢谢。
你遗漏了“使结果值base64编码”。 '$ sig = base64_encode($ sig);' – 2014-09-03 20:43:11
您之前询问的问题的副本 – 2014-09-03 20:46:17
@RocketHazmat我添加了它并仍然出现错误:错误的请求签名UPL-TYQTSBHIYGRFHKXEPJNPELGY – Toni 2014-09-03 21:14:52