使用 Google Scripts 的 Binance API 签名 [英] Binance API Signature with Google Scripts

查看:24
本文介绍了使用 Google Scripts 的 Binance API 签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困在如何根据 Binance API<正确地将签名包含到我的 get 命令中/a> 在 Google Scripts 中.它说的是

I am stuck on how to correctlly include the signitue into my get command based off of the Binance API within Google Scripts. What it states is

SIGNED 端点需要在查询字符串或请求正文中发送附加参数签名.端点使用 HMAC SHA256 签名.HMAC SHA256 签名是加密的 HMAC SHA256 操作.使用您的 secretKey 作为密钥,使用 totalParams 作为 HMAC 操作的值.签名不区分大小写.totalParams 定义为与请求正文连接的查询字符串.

SIGNED endpoints require an additional parameter, signature, to be sent in the query string or request body. Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your secretKey as the key and totalParams as the value for the HMAC operation. The signature is not case sensitive. totalParams is defined as the query string concatenated with the request body.

我拥有的是:

function BinanceTrades() {
  var curTime = Number(new Date().getTime()).toFixed(0)
  var sKey = Utilities.computeHmacSha256Signature('symbol=LTCBTC&timestamp=' + curTime, '**mySeceretKey**');
  Logger.log(sKey)
  var headers = {'X-MBX-APIKEY': '**myKey**'}
  var data = UrlFetchApp.fetch("https://api.binance.com/api/v3/allOrders?signature=" + sKey + "&symbol=LTCBTC&timestamp=" + curTime, {'headers' : headers})
  Logger.log(data)
}

我得到的错误是:

{"code":-1100,"msg":"在参数'signature'中发现非法字符;合法范围是'^[A-Fa-f0-9]{64}$'."}

{"code":-1100,"msg":"Illegal characters found in parameter 'signature'; legal range is '^[A-Fa-f0-9]{64}$'."}

我不确定如何正确计算 HMAC SHA256 并合并 totalParams.

I am unsure of how to compute the HMAC SHA256 correctly and incorporate the totalParams.

我之前的帖子是这个.

推荐答案

这些修改怎么样?

来自您提供的手册

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆