2017-10-26 9 views
-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"}]} 

答えて

0

は次のようにシグネチャを作成します。

$time = time(); 
$method = "GET"; 
$path = 'accounts'; 
$sign = base64_encode(hash_hmac("sha256", $time.$method.$path, base64_decode($g_coinbase_secret), true)); 

$ch = curl_init('https://api.coinbase.com'.$path); 

を置き換えます3210

$ch = curl_init('https://api.coinbase.com/v2/');