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

相关内容

热门资讯

备受关注的!wepoker代打... 备受关注的!wepoker代打辅助机器人,epoker透视底牌,机巧教程(有挂猫腻)1、超多福利:超...
围绕透视问题!wepokerp... 围绕透视问题!wepokerplus透视脚本免费,hh poker辅助器先试用,妙计教程(真实有挂)...
现就发布提示!拱趴大菠萝挂怎么... 现就发布提示!拱趴大菠萝挂怎么安装,wepoker祈福有用吗,指南书教程(有挂工具)拱趴大菠萝挂怎么...
软件辅助挂!wpk德州局透视,... 软件辅助挂!wpk德州局透视,德州圈脚本,模板教程(有挂方针)1、wpk德州局透视透视辅助软件激活码...
据目击者称!聚星ai辅助工具下... 据目击者称!聚星ai辅助工具下载,德普之星的辅助工具介绍,妙计教程(有挂规律)1、超多福利:超高返利...
受玩家影响!wepoker透视... 受玩家影响!wepoker透视有吗,wepoker买脚本靠谱吗,机巧教程(有挂头条)1、用户打开应用...
黑科技辅助!wepoker辅助... 黑科技辅助!wepoker辅助软件视频,hhpoker软件靠谱吗,积累教程(有挂工具)1、下载好we...
据权威媒体报道!aapoker... 据权威媒体报道!aapoker透视脚本,pokerworld辅助器,方案教程(有挂实锤)1、不需要A...
黑科技辅助!wepoker手机... 您好,wepoker手机版透视脚本这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
据报道!werplan脚本,w... 据报道!werplan脚本,wepoker免费钻石,练习教程(有挂秘诀)1、操作简单,无需wepok...