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

相关内容

热门资讯

现有关情况通报如下!wepok... 现有关情况通报如下!wepoker辅助器安装包(透视)吉祥填大坑有什么诀窍(果然真的是有辅助神器)-...
透视大纲!佛手大菠萝辅助(透视... 透视大纲!佛手大菠萝辅助(透视)菠萝德普辅助器免费版在哪里(辅助)果然一直都是有技巧(哔哩哔哩)1、...
有消息称!wepoker免费脚... 有消息称!wepoker免费脚本咨询(透视)衢州都莱罗松挂机技巧(好像是有辅助app)-哔哩哔哩;该...
透视机巧!pokermaste... 透视机巧!pokermaster脚本(透视)pokemmo辅助脚本(辅助)原来一直总是有攻略(哔哩哔...
透视智能ai!hhpoker辅... 透视智能ai!hhpoker辅助挂是真的吗(透视)新蜜瓜大厅破解(一直真的是有辅助辅助器)-哔哩哔哩...
透视总结!约局吧作必弊脚本(透... 透视总结!约局吧作必弊脚本(透视)红龙poker有辅助吗(辅助)确实真的是有脚本(哔哩哔哩)一、约局...
据监测!aa poker辅助(... 据监测!aa poker辅助(透视)楚天游卡五星辅助器(确实存在有辅助工具)-哔哩哔哩1、每一步都需...
透视学习!智星德州可以透视吗(... 透视学习!智星德州可以透视吗(透视)xpoker辅助控制(辅助)真是一直都是有攻略(哔哩哔哩)1)智...
随着!aa poker辅助包(... 随着!aa poker辅助包(透视)科乐游戏辅助脚本视频(都是真的有辅助工具)-哔哩哔哩1、首先打开...
透视总结!werplan免费挂... 透视总结!werplan免费挂下载(透视)poker world辅助器(辅助)真是一直总是有app(...