我正在通過一個拉拉維爾項目來運行這個東西。我已經把頭發扯了一段時間了。到目前為止,我所擁有的是從科因基專業版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);我得到的響應是無效的簽名。我很困惑,任何幫助都非常感謝。
1 回答

慕容森
TA貢獻1853條經驗 獲得超18個贊
因此,經過多次擺弄,我發現我缺少一個內容類型標題,所以我添加了:
"Content-Type: application/json"
添加到CURLOPT_HTTPHEADER數組。我希望這可以幫助某人!
- 1 回答
- 0 關注
- 81 瀏覽
添加回答
舉報
0/150
提交
取消