我正在尝试将 API 用于 Coinbase,但我得到了无效的签名。
所以可能我实际上签错了,或者我遗漏了一些东西。
我应该根据要求使用什么?我应该在方法上使用 POST 还是 GET ?
$urlapi = "https://api.coinbase.com/v2/time";
$Key = "--------------";
$Secret = "------------";
$fecha = new DateTime();
$timestamp = $fecha->getTimestamp();
$request="";
$body="";
$method="GET";
$Datas = $timestamp . $method . $request . $body;
$hmacSig = hash_hmac('sha256',$Datas,$Secret);
$curl = curl_init($urlapi);
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type: application/json','CB-ACCESS-KEY: '.$Key,'CB-VERSION: 2015-07-07','CB-ACCESS-TIMESTAMP: '. $timestamp,'CB-ACCESS-SIGN: '.$hmacSig));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
if(!curl_exec($curl)){
die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
}
curl_close($curl);
print_r($resp);