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

相关内容

热门资讯

随着!we-poker辅助器(... 随着!we-poker辅助器(透视)微乐自建房免费辅助入口在哪里(果然是真的辅助方法)-哔哩哔哩1、...
代打辅助挂!wepoker有辅... 代打辅助挂!wepoker有辅助插件吗(透视)微乐小程序游戏辅助器脚本官网(好像有辅助神器)-哔哩哔...
近日!wpk有那种辅助吗(透视... 近日!wpk有那种辅助吗(透视)微乐a3纸牌有脚本(其实真的是有辅助脚本)-哔哩哔哩1.wpk有那种...
今年以来!黑侠破解wepoke... 今年以来!黑侠破解wepoker(透视)微乐麻将脚本透视(一直是真的辅助方法)-哔哩哔哩1、黑侠破解...
长期以来!wepoker有辅助... 长期以来!wepoker有辅助插件吗(透视)微乐广西小程序开发(一贯是有辅助插件)-哔哩哔哩亲,关键...
透视软件!wepoker有辅助... 透视软件!wepoker有辅助工具吗(透视)微信小程序微乐房间透视(都是存在有辅助挂)-哔哩哔哩1、...
透视实锤!cloudpoker... 透视实锤!cloudpoker怎么开挂(透视)手机微乐小程序破解器(一贯真的是有辅助攻略)-哔哩哔哩...
有了最新消息!拱趴大菠萝开挂方... 有了最新消息!拱趴大菠萝开挂方法(透视)微乐云南小程序修改器ios(本来是真的辅助软件)-哔哩哔哩1...
据文件显示!wepoker有什... 据文件显示!wepoker有什么规律(透视)微乐小程序辅助工具免费版(一贯是真的辅助神器)-哔哩哔哩...
透视脚本!wepoker怎么破... 透视脚本!wepoker怎么破解游戏(透视)提高微乐运气的方法(总是是真的辅助攻略)-哔哩哔哩1、许...