【发布时间】:2018-11-06 17:31:29
【问题描述】:
我尝试访问 Binance API 的 https://api.binance.com/wapi/v3/withdraw.html 端点
我需要在标头中使用我的 API 密钥和请求正文中的参数作为发布订单发送它。
我的代码是用 c++ 编写的,我正在使用 libcurl。
hmac_sha256() 函数也在工作。
我有这个代码:
bool BinanceAPI::make_Withdrawal(string api_key , string secret_key ,string asset , string address , double amount , string &id ){
cout << "BINANCE: MAKE WITHDRAWAL"<<endl;
ArbUtils au;
Json::Value result;
CURL * hand;
bool ret = false;
hand = curl_easy_init();
string url = "https://api.binance.com/wapi/v3/withdraw.html";
string post_data("asset=");
post_data.append( asset);
post_data.append("&address=");
post_data.append(address);
post_data.append( "&amount" );
post_data.append( to_string(amount) );
post_data.append( "×tamp=" );
post_data.append( to_string(au.get_msTime() ) );
string signature = hmac_sha256( secret_key.c_str() , post_data.c_str());
post_data.append( "&signature=" );
post_data.append( signature );
vector<string>extra_http_header;
string header_chunk("X-MBX-APIKEY: ");
header_chunk.append( api_key );
extra_http_header.push_back( header_chunk );
string str_result;
curl_easy_setopt(hand , CURLOPT_URL , url.c_str() );
curl_easy_setopt(hand , CURLOPT_WRITEFUNCTION , BinanceAPI::callback);
curl_easy_setopt(hand , CURLOPT_WRITEDATA , &str_result );
curl_easy_setopt(hand , CURLOPT_SSL_VERIFYPEER , false);
curl_easy_setopt(hand , CURLOPT_ACCEPT_ENCODING , "gzip" );
curl_easy_setopt(hand , CURLOPT_POST , 1);
struct curl_slist *chunk = NULL;
for(int i= 0 ; i < extra_http_header.size() ; i++){
chunk = curl_slist_append(chunk , extra_http_header[i].c_str() );
}
curl_easy_setopt(hand , CURLOPT_HTTPHEADER , chunk);
curl_easy_setopt(hand , CURLOPT_POSTFIELDS , post_data.c_str() );
CURLcode res;
res = curl_easy_perform(hand);
curl_easy_cleanup(hand);
}
我现在从服务器收到一条错误消息:
代码:-1105 msg: "参数 'payload' 为空"
我尝试并询问了支持,但他们也不知道答案。 我不知道为什么会这样。我有其他通过相同结构访问的端点,它们也需要完全相同的形式并且它们可以工作。
知道为什么会发生这种情况吗?
【问题讨论】: