【问题标题】:Use matlab connunicate to bittrex api error (APISIGN_NOT_PROVIDED)使用 matlab 连接到 bittrex api 错误 (APISIGN_NOT_PROVIDED)
【发布时间】:2018-04-19 22:31:35
【问题描述】:

我有以下代码,我还阅读了 Bittrex 的帖子。我的 nonce 和 apikey 用于 HMAC 计算,但我收到 APISIGN_NOT_PROVIDED 错误。

对于这个版本,我们使用标准的 HMAC-SHA512 签名。附加 apikey 和随机数到您的请求并计算 HMAC 哈希并包含它 在 apisign 标题下。注意:nonce 现在不被尊重 但稍后会强制执行。

if true
  % code
url_base = 'https://bittrex.com/api/v1.1/market/getopenorders';
body = [url_base,'?apikey=',apikey,'&nonce=',nonce];
sign = hmac(secret_key, body, 'SHA-512');
json = urlread( body, 'Get', {'apisign', sign} )
end

【问题讨论】:

    标签: matlab api


    【解决方案1】:

    由于不再推荐urlread(参考here),出于好奇,尝试当前推荐的替代webread

    url_base = 'https://bittrex.com/api/v1.1/market/getopenorders/';
    url_full = [url_base '?apikey=' apikey '&nonce=' nonce];
    sign = hmac(secret_key,url_full,'SHA-512');
    
    opt = weboptions('ContentType','json','HeaderFields',{'apisign' sign},'RequestMethod','get');
    json = webread(url_full,opt);
    

    此外,不要忘记在代码中放置断点并检查 sign 的外观,以确保您在 HTTPS 请求标头中转发格式正确的数据。

    【讨论】:

      猜你喜欢
      • 2014-04-22
      • 1970-01-01
      • 2019-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多