我正在通过一个拉拉维尔项目来运行这个东西。我已经把头发扯了一段时间了。到目前为止,我所拥有的是从科因基专业版API文档中摘录的。
$request_path = "/orders";
$body = array('size' => $size, 'price' => $eth_price, 'side' => 'sell', 'product_id' => 'ETH-GBP' );
$body = is_array($body) ? json_encode($body) : $body;
$secret = my secret;
$ch = curl_init("https://api.pro.coinbase.com/time");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch,CURLOPT_USERAGENT,'CoinbaseProAPI');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch));
curl_close($ch);
$timestamp = $result->epoch;
$timestamp_rounded = intval(ceil($timestamp));
$what = $timestamp_rounded.'POST'.$request_path.$body;
$sig = base64_encode(hash_hmac("sha256", $what, base64_decode($secret), true));
$ch = curl_init("https://api.pro.coinbase.com".$request_path) ;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($ch,CURLOPT_USERAGENT,'CoinbaseProAPI');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'CB-ACCESS-KEY: public_key',
'CB-ACCESS-SIGN: '.$sig,
'CB-ACCESS-PASSPHRASE: passphrase',
'CB-ACCESS-TIMESTAMP: '.$timestamp));
$coinbasepro_response = curl_exec($ch) ;
curl_close($ch) ;
dd($coinbasepro_response);
我得到的响应是无效的签名。我很困惑,任何帮助都非常感谢。
慕容森