Bitstamp API发布请求C ++

时间:2018-07-11 13:15:04

标签: c++ api bitcoin

我正在尝试使用API​​отС++访问Bitstamp帐户的余额。因此,我使用以下代码:

CURL *curl_handle;
string readBuffer;
curl_global_init(CURL_GLOBAL_ALL);

curl_handle = curl_easy_init();
string message = to_string(getNonce()) + customer_id + apikey;
string signature = hmac_sha256(apisecret.c_str(), message.c_str()); 

stringstream ssSignature;
ssSignature << "key=" << apikey << "&";
ssSignature << "signature=" << signature << "&";
ssSignature << "nonce=" <<  to_string(getNonce()) ;

curl_easy_setopt(curl_handle, CURLOPT_URL, (const char* ) ssURL.str().c_str());

struct curl_slist *headerlist = NULL;
headerlist = curl_slist_append(headerlist, "Content-Type: application/x-www-form-urlencoded" );

curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl_handle, CURLOPT_POST,  true );
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS,  (const char*) ssSignature.str().c_str() );

curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writerToString);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &readBuffer);

CURLcode ans = curl_easy_perform(curl_handle);

但是,不幸的是,每次我收到错误消息:

"{\"status\": \"error\", \"reason\": \"Missing key, signature and nonce parameters.\", \"code\": \"API0000\"}"

你能告诉我我错过了什么吗?

0 个答案:

没有答案