我正在尝试使用hawk来验证对hawk服务器的请求。我已经收到一个共享密钥,哈希函数和标识符。我创建一个标题:
$uri = 'https://api.onslip360.com/v1/~abc.123/products';
$request = $client->createRequest(
$credentials,
$uri,
'GET'
);
$curlHeaders[] = 'Authorization: '.$request->header()->fieldValue();//$header;
function cUrlGetData($url, $post_fields = null, $headers = null)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
if ($post_fields && !empty($post_fields))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
}
if ($headers && !empty($headers))
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
if (curl_errno($ch))
{
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
return $data;
}
$resp = cUrlGetData($uri, $postFields, $curlHeaders);
但是服务器回复:
我怀疑我的鹰头和要求不匹配,但是我看不出有什么问题。
以上,我使用了dflydev hawk并失败了。我也尝试过使用shawn11 hawk来获得相同的结果。