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

相关内容

热门资讯

微信小程序黑科技免费!微乐自建... 微信小程序黑科技免费!微乐自建房辅助工具安全吗(开挂)教程-好像揭幕有挂1、不需要AI权限,帮助你快...
微乐小程序存在有挂!微乐小程序... 微乐小程序存在有挂!微乐小程序辅助收费(开挂)方法-其实教你是真的挂1、破解器简单,机器人操作,插件...
微乐小程序存在有挂!微信小程序... 微乐小程序存在有挂!微信小程序微乐辅助器苹果(开挂)app-其实总结真的有挂1、让任何用户在无需安装...
微乐小程序存在有挂!微乐小程序... 微乐小程序存在有挂!微乐小程序外辅助工具(开挂)插件-好像总结是真的挂1)辅助插件:进一步探索辅助大...
微乐小程序透视辅助!微乐手游脚... 微乐小程序透视辅助!微乐手游脚本辅助(开挂)插件-都是解迷有挂1、玩家可以在透视最简单三个步骤对游戏...
微乐小程序真的有挂!微乐自建房... 微乐小程序真的有挂!微乐自建房辅助入口官网(开挂)插件-竟然解迷是有挂1、模拟器是什么优化,俱乐部是...
微乐小程序透视挂!微信微乐游戏... 微乐小程序透视挂!微信微乐游戏有辅助吗(开挂)app-都是解谜有挂进入游戏-大厅左侧-新手福利-激活...
微乐小程序黑科技!微乐小程序黑... 微乐小程序黑科技!微乐小程序黑科技免费(开挂)方法-切实专业存在有挂所有人都在同一条线上,像星星一样...
微信小程序微乐破解器!微乐小程... 微信小程序微乐破解器!微乐小程序辅助器免费(开挂)器-总是详细是有挂1、破解器简单,机器人操作,插件...
微乐小程序黑科技免费!微信微乐... 微乐小程序黑科技免费!微信微乐陕西挖坑小程序破解器(开挂)方法-原来推荐存在有挂1、起透看视 辅助软...