这是币安加密货币交易所 API。我试图获取帐户信息,但我无法做到这一点。它是官方 C++ Api。这是github链接 https://github.com/binance-exchange/binacpp。这是终端上的错误。回答问题时,请轻松一点。我是新手
2020-01-22 10:32:04 085219 :
2020-01-22 10:32:04 085245 : 网址 = |https://api.binance.com/api/v1/userDataStream| https://api.binance.com/api/v1/userDataStream%7C
2020-01-22 10:32:04 085253 :
2020-01-22 10:32:04 698466 :
2020-01-22 10:32:04 698529 : 完成
2020-01-22 10:32:04 701234 : 完成
2020-01-22 10:32:04 701434:完成。
2020-01-22 10:32:04 701472:完成。
{
“代码”:-2015,
"msg" : "无效的 API 密钥、IP 或操作权限。"
}
[2020/01/22 10:32:04:7018] 注意:libuv 支持未编译
[2020/01/22 10:32:04:7045] 注意:创建虚拟主机“默认”端口 -1、1 协议、IPv6 关闭
[2020/01/22 10:32:04:7046] 注意:创建了默认的客户端 ssl 上下文
[2020/01/22 10:32:04:7099] 注意:lws_client_connect_2:0x239f3e0:地址stream.binance.com
[2020/01/22 10:32:05:3128] 注意:lws_client_connect_2:0x239f3e0:地址stream.binance.com
我在这里输入了我的钥匙。
using namespace std;
#define API_KEY "my api key here,deleted for security"
#define SECRET_KEY "secret key is here, deleted for security"
和主要功能
int main() {
Json::Value result;
long recvWindow = 10000;
string api_key = API_KEY;
string secret_key = SECRET_KEY;
BinaCPP::init( api_key , secret_key );
// User Balance
BinaCPP::get_account( recvWindow , result );
for ( int i = 0 ; i < result["balances"].size() ; i++ ) {
string symbol = result["balances"][i]["asset"].asString();
userBalance[symbol]["f"] = atof( result["balances"][i]["free"].asString().c_str() );
userBalance[symbol]["l"] = atof( result["balances"][i]["locked"].asString().c_str() );
}
print_userBalance();
// User data stream
BinaCPP::start_userDataStream(result );
cout << result << endl;
string ws_path = string("/ws/");
ws_path.append( result["listenKey"].asString() );
BinaCPP_websocket::init();
BinaCPP_websocket::connect_endpoint( ws_userStream_OnData , ws_path.c_str() );
BinaCPP_websocket::enter_event_loop();
}
这是 BinaCPP.cpp 的一部分
#include "binacpp.h"
#include "binacpp_logger.h"
#include "binacpp_utils.h"
string BinaCPP::api_key = "my api key here";
string BinaCPP::secret_key = "secret key here";
CURL* BinaCPP::curl = NULL;
//---------------------------------
void
BinaCPP::init( string &api_key, string &secret_key )
{
curl_global_init(CURL_GLOBAL_DEFAULT);
BinaCPP::curl = curl_easy_init();
BinaCPP::api_key = api_key;
BinaCPP::secret_key = secret_key;
}