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参数进行正确的传递。

相关内容

热门资讯

开挂辅助工具"wep... 开挂辅助工具"wepokerplus辅助"开挂(透视)辅助平台(详细教程);打开点击测试直接进入微信...
开挂辅助软件"德州圈... 大家好,今天小编来为大家解答德州圈脚本这个问题咨询软件客服可以免费测试直接加微信(136704302...
开挂辅助平台"wep... 【亲,wepoker破解游戏盒子 这款游戏可以开挂的,确实是有挂的,很多玩家在这款wepoker破解...
开挂辅助插件"We ... 开挂辅助插件"We poker辅助器下载"开挂(透视)辅助脚本(存在有挂)>>您好:软件加薇1367...
开挂辅助下载"wep... wepoker私人局可以透视是一款可以让一直输的玩家,快速成为一个“必胜”的ai辅助神器,有需要的用...
开挂辅助软件"wep... 开挂辅助软件"wepoker代打辅助机器人"开挂(透视)辅助脚本(有挂教程)【无需打开直接搜索加薇1...
开挂辅助工具"wep... 开挂辅助工具"wepoker轻量版有透视吗"开挂(透视)辅助神器(真的有挂) 了解更多开挂安装加(1...
开挂辅助插件"we ... 开挂辅助插件"we poker免费辅助器"开挂(透视)辅助神器(今日头条)您好:we poker免费...
开挂辅助工具"hhp... 开挂辅助工具"hhpkoer辅助器视频"开挂(透视)辅助平台(有挂实锤) 【无需打开直接搜索加薇13...
开挂辅助工具"hhp... 开挂辅助工具"hhpoker德州辅助"开挂(透视)辅助平台(有挂猫腻)>>您好:软件加1367043...