我正在尝试按照此处的建议生成签名:https://www.reed.co.uk/developers/SignatureTest
这就是他们在页面底部所说的内容。但我不明白这一点!
If you use a language like C\C++ and Perl, your processor architecture could generated different arrangement of bits for your API Key.
Check at the section below if your API key bytes are arranged in the same way that we use to validate your signature.
API Token (Hexadecimal Notation)
[0x5A] [0x74] [0xD7] [0xDA] [0x32] [0x16] [0x62] [0x47] [0xA8] [0x55] [0x64] [0xC6] [0xA7] [0xC4] [0x0B] [0x56]
How can I fix it ?
If the arrange of bits is not the same, this might be a indication that it is in a little endian format.
You will need to swap the bytes from one little endian to big endian to get achieve the same signature. You can find more about Byte Swapping Libraries searching on Google or Bing .
这就是我在做的事情:
function createSignature($queryUrl, $timestamp, $apiKey, $http = "GET", $agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"){
$signature = $http . $agent . $queryUrl . "www.reed.co.uk" . $timestamp;
$signature = base64_encode(hash_hmac("sha1", $signature, $apiKey, true));
return $signature;
}
$clientId = 1;
$timestamp = "2016-05-13T09:22:50Z";
$apiKey = "bacd2d2d-8b69-43c8-94c5-4a24c0269b79";
$queryUrl = "https://www.reed.co.uk/recruiter/api/1.0/cvsearch";
$reedQuery = \Httpful\Request::get($queryUrl)
->addHeaders(array(
"X-ApiSignature" => createSignature($queryUrl, $timestamp, $apiKey),
"X-ApiClientId" => $clientId,
"X-TimeStamp" => $timestamp
))
->expectsJson()
->send();
现在由于某些原因它在我的服务器上返回:WRTjqQKfyEQyLJEzWWuT3SWgGPk =预期结果为:JUgvCh5oeFYe1HDmfiMObOu1 + nQ =
我尝试了一切,甚至从小端到大端。什么都没有。
有什么问题? :(