ByBitApi.打开活动订单返回timestamp参数为空使用Libcurlc++
创始人
2025-01-12 20:00:46
0

该问题是由于API请求中timestamp参数为空导致的。可以通过使用Libcurl c++的代码示例来解决如下:

#include 
#include 
#include 
#include 

std::string bybitApiSignature(const std::string& secret, const std::string& verb, const std::string& url, const int64_t& expires, const std::string& body) {
    std::stringstream prehash;
    prehash << verb << url << expires << body;
    const std::string message = prehash.str();

    std::vector result(HMAC_SHA256_DIGEST_LENGTH);
    HMAC_SHA256(result.data(), secret.c_str(), secret.size(), message.c_str(), message.size());

    return base64_encode(result.data(), result.size());
}

int main() {
    CURL* curl;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();

    std::string verb = "GET";
    std::string endpoint = "/open-api/order/list";
    std::string params = "limit=10&order_status=New";
    const int64_t expires = get_current_timestamp() + 10;
    const std::string body = "";

    std::stringstream ss;
    ss << "https://api.bybit.com" << endpoint << "?api_key=" << apikey << "&" << params
        << "×tamp=" << expires << "&sign=" << bybitApiSignature(secret, verb, endpoint, expires, body);

    std::string url = ss.str();

    if (curl) {
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
        curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();
    return 0;
}

其中,需要注意对timestamp参数进行正确的传递。

相关内容

热门资讯

德州之星插件!aapoker怎... 德州之星插件!aapoker怎么设置牌局,wepower使用说明书,线上教程(有挂攻略)是一款可以让...
wepoke模拟器!wopok... wepoke模拟器!wopoker辅助器ios,wepoke 软件,微扑克教程(有挂方法)1、在we...
智星德州菠萝外挂!德州辅助软件... 智星德州菠萝外挂!德州辅助软件线上,cloudpoker外挂,规律教程(有挂教学)1、不需要AI权限...
wepoke辅助德之星!wpk... wepoke辅助德之星!wpk透视辅助封号吗,wpk外挂存在,安装教程(有挂攻略);人气非常高,ai...
wpk发牌逻辑!wepoke有... wpk发牌逻辑!wepoke有辅助挂吗,微扑克辅助工具可以下载,技巧教程(有挂了解),您好,wepo...
aapoker俱乐部!菠萝德州... aapoker俱乐部!菠萝德州辅助软件,wepower有外挂,切实教程(有挂教程)1、aapoker...
智星德州菠萝外挂!pokerx... 智星德州菠萝外挂!pokerx机器人,wepoke软件透明挂多少钱,解密教程(有挂规律)1、智星德州...
wepoke ai辅助!微扑克... wepoke ai辅助!微扑克wpk,微扑克ai操作,2025版教程(有挂详情)1、不需要AI权限,...
wpk透视辅助测试!aapok... wpk透视辅助测试!aapoker系统机制,wepoke是有辅助,切实教程(有挂规律)1.wpk透视...
wepoke一定有挂!德扑ai... wepoke一定有挂!德扑ai助手软件,德州wepower透视辅助,技巧教程(有挂透明)1、wepo...