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

相关内容

热门资讯

透视能赢!哈糖大菠萝有挂吗5个... 透视能赢!哈糖大菠萝有挂吗5个常用方法,来玩德州破解器,解密教程(有挂介绍);1、起透看视 哈糖大菠...
透视中牌率!佛手在线有挂吗,e... 透视中牌率!佛手在线有挂吗,epoker免费透视脚本,介绍教程(有挂教程)一、epoker免费透视脚...
透视存在!pokemmo辅助脚... 透视存在!pokemmo辅助脚本,哈糖大菠萝挂,教你攻略(有挂技巧)1)pokemmo辅助脚本辅助挂...
透视科技!德州真人透视脚本,w... 透视科技!德州真人透视脚本,werplan怎么透视,黑科技教程(有挂详情)1、下载好德州真人透视脚本...
透视神器!约局吧德州透视,we... 透视神器!约局吧德州透视,werplan脚本,wpk教程(有挂技巧)1、游戏颠覆性的策略玩法,独创攻...
透视免费!哈糖大菠萝有挂吗5个... 透视免费!哈糖大菠萝有挂吗5个常用方法,菠萝德普辅助器免费版在哪里,规律教程(有挂方法)1)哈糖大菠...
透视透视挂!pokernow辅... 透视透视挂!pokernow辅助控制,哈糖大菠萝万能挂,专业教程(有挂详情)在进入哈糖大菠萝万能挂辅...
透视存在!线上德州的辅助器是什... 透视存在!线上德州的辅助器是什么,pokemmo脚本手机版,2025教程(有挂黑科技)1、线上德州的...
透视智能ai!哈糖大菠萝怎么挂... 透视智能ai!哈糖大菠萝怎么挂,pokerworld修改器,新2025教程(有挂工具)暗藏猫腻,小编...
透视工具!约局吧能不能开挂,菠... 透视工具!约局吧能不能开挂,菠萝辅助器免费版的功能介绍,2025教程(有挂技巧);1、每一步都需要思...