-1
API coinbase.com에 대한 요청을 쓰려고하는데 서명을 올바르게 생성 할 수 없습니다. 나는 2 일 동안 나의 실수를 찾으려고 노력했지만, 나는 그럴 수 없다. 페이지의 다른 언어에 대한 코드를 분석했습니다 : https://developers.coinbase.com/docs/wallet/api-key-autumnicathion하지만 구현에 차이점은 없습니다.코인베이스의 API 키 인증
도와주세요.
<?php
$g_coinbase_key = 'KcxisxqmWRVgtwsj';
$g_coinbase_secret = 'isOLGBLaEkCy3ROQMvmjonGmXK0KRmUS';
$time = time();
$method = "GET";
$path = '/v2/accounts/';
$sign = base64_encode(hash_hmac("sha256", $time.$method.$path, $g_coinbase_secret));
$ch = curl_init('https://api.coinbase.com'.$path);
$headers = array(
"CB-VERSION: 2017-10-26",
"CB-ACCESS-SIGN: ".$sign,
"CB-ACCESS-TIMESTAMP: ".$time,
"CB-ACCESS-KEY: ".$g_coinbase_key,
"Content-Type: application/json"
);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
var_dump($result);
?>
결과 :
{"errors":[{"id":"authentication_error","message":"invalid signature"}]}