【问题标题】:Connecting to Coinex API issue连接到 Coinex API 问题
【发布时间】:2021-10-29 10:46:42
【问题描述】:

我尝试通过 Java 程序连接到 Coinex API 我按照下面链接中提到的确切模式进行授权

https://github.com/coinexcom/coinex_exchange_api/wiki/012security_authorization

我的 MD5 有完整的查询字符串,如下所示,并将结果放入请求头参数中的授权

 tonce=1635504041595&access_id=XXXX&secret_key=YYYY

我的目的是获取帐户余额,因此我的 Get 请求 URL 是

https://api.coinex.com/v1//balance/info?tonce=1635504041595&access_id=XXXX

但服务器返回以下错误

{"code": 25, "data": {}, "message": "Signature Incorrect"}

任何人都可以提出问题,谢谢 AndyJ

【问题讨论】:

    标签: rest get authorization


    【解决方案1】:

    这是我的编码方法:

    public static String encode(String str) {
        try {
            // Generate a summary of MD5 encryption calculations
            MessageDigest md = MessageDigest.getInstance("MD5");
    
            md.update(str.getBytes("UTF-8"));
            // digest() finally determines to return the md5 hash value, returning a value of 8 as a string. Because the md5 hash value is a 16-bit hex value, it is actually an 8-bit character.
            // The BigInteger function converts an 8-bit string into a 16-bit hex value, represented by a string; gets a hash value in the form of a string
            String md5 = new BigInteger(1, md.digest()).toString(16);
            //BigInteger will omit 0 and need to be completed to 32 bits
            return fillMD5(md5).toUpperCase();
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
    

    还有一件事, 你的时间图应该有 10 位数字,像这样删除最后 3 个“000”:

    Integer.parseInt(String.valueOf(timestamp).substring(0, 10));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-24
      • 2022-11-18
      • 2020-05-30
      • 1970-01-01
      • 2013-08-23
      • 2017-10-12
      • 1970-01-01
      • 2019-01-23
      相关资源
      最近更新 更多