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

相关内容

热门资讯

实操分享!小程序游戏赴沪期(辅... 实操分享!小程序游戏赴沪期(辅助挂)hh poker辅助有用吗(一直有挂)是一款可以让一直输的玩家,...
揭秘几款!微乐河南麻将辅助io... 揭秘几款!微乐河南麻将辅助ios(辅助挂)wepoker有没有机器人(其实有挂);微乐河南麻将辅助i...
教程辅助!德扑之星私人局辅助(... 教程辅助!德扑之星私人局辅助(辅助挂)wepoker养号规律(真是有挂)是一款可以让一直输的玩家,快...
技巧知识分享!广东闲来辅助神器... 您好,广东闲来辅助神器免费版这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多...
记者揭秘!小闲川南手游辅助器(... 记者揭秘!小闲川南手游辅助器(辅助挂)hhpoker哪个俱乐部靠谱(确实是有挂);大家肯定在之前小闲...
玩家交流!小程序牵手跑得有辅助... 《玩家交流!小程序牵手跑得有辅助器(辅助挂)竞技联盟辅助插件(本来存在有挂)》 小程序牵手跑得有辅助...
玩家必看分享!传送屋挂件(辅助... 玩家必看分享!传送屋挂件(辅助挂)wepoker透视版下载(好像有挂);是一款可以让一直输的玩家,快...
一起来探讨!威信茶馆透视挂(辅... 一起来探讨!威信茶馆透视挂(辅助挂)竞技联盟辅助插件(素来有挂);一、威信茶馆透视挂AI软件牌型概率...
必看攻略!微乐小程序辅助收费(... 必看攻略!微乐小程序辅助收费(辅助挂)pokemmo手机版脚本(本来有挂);1、微乐小程序辅助收费a...
一分钟了解!川娱竞技辅助插件(... 一分钟了解!川娱竞技辅助插件(辅助挂)hhpoker有后台操作吗(本然是真的有挂);川娱竞技辅助插件...