根据此处https://www.bitstamp.net/api/的Bitstamp API文档,以下Python代码可用于生成SHA256签名:
import hmac
import hashlib
message = nonce + customer_id + api_key
signature = hmac.new(
API_SECRET,
msg=message,
digestmod=hashlib.sha256
).hexdigest().upper()
我正在尝试将Laravel / PHP与GuzzleHttp Client一起使用。我的代码是:
$client = new \GuzzleHttp\Client();
$nonce = time();
$message = $nonce . $bitstamp_customer_id . $bitstamp_api_key;
$signature = strtoupper(hash_hmac("sha256", $message, $bitstamp_api_secret));
$response = $client->request('POST', 'https://www.bitstamp.net/api/v2/balance/', [
'form_params' => [
'key' => $bitstamp_api_key,
'signature' => $signature,
'nonce' => $nonce,
]
]);
无论我尝试什么,我都会得到:
Client error:
POST https://www.bitstamp.net/api/v2/balance/ resulted in a
403身份验证失败response: {"status": "error", "reason": "API key not found", "code": "API0001"}
我已经检查了三个关键的Bitstamp参数,并多次重新创建了API密钥。我检查过的三个参数是:
我得出的结论是我没有正确翻译Python代码,并且需要帮助。
答案 0 :(得分:0)
天哪,我必须按下绿色的ACTIVATE大按钮并通过电子邮件进行确认。