[英]Coinbase API - invalid signature
I'm trying to use the API for Coinbase but I get invalid signature.我正在尝试将 API 用于 Coinbase,但我得到了无效的签名。 So probably I'm actually sign it wrong or I'm missing something.
所以可能我实际上签错了,或者我遗漏了一些东西。 please help me.
请帮我。
$API_KEY = "-------";
$API_SECRET = "------";
$USER_ID = "------",
$timestamp = time();
$method = "POST";
$path = '/v2/accounts/'.$USER_ID.'/addresses';
$message = $timestamp . $method . $path ;
$signature = hash_hmac('SHA256', $message, $API_SECRET);
$version = '2017-11-11';
$headers = array(
'CB-ACCESS-SIGN: ' . $signature,
'CB-ACCESS-TIMESTAMP: ' . $timestamp,
'CB-ACCESS-KEY: ' . $API_KEY,
'CB-VERSION: ' . $version
);
$body = array(
'name: New receive address'
);
$api_url = "https://api.coinbase.com/v2/accounts/'.$USER_ID.'/addresses";
$curl = curl_init($api_url);
curl_setopt($curl,CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl,CURLOPT_POSTFIELDS, $body);
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);
results api:结果 api:
{"errors":[{"id":"authentication_error","message":"invalid signature"}]}
I'm currently working on this and just got this right (in Elixir).我目前正在研究这个并且刚刚做对了(在 Elixir 中)。 I think there are two problems:
我认为有两个问题:
$message
in this context) to generate the signature.$message
)以生成签名。 You should try this with a simple GET request on a Wallet endpoint before proceeding with this IMHO.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.