我试图请求yobit API wr.以便访问完成身份验证所需的一些方法:
每个贸易API请求都应该通过身份验证。通过发送以下HTTP来完成身份验证:
密钥- API-key,示例: FAF816D16FFDFBD1D46EEF5D5B10D8A2
签名-数字签名,后参数(?param0=val0 & ...& nonce=1),通过HMAC-SHA512 512由密匙签名
在随后的请求中,参数的值应该超过前一个请求中的值(1最小到2147483646最大值)。若要null,则需要生成新密钥.。
我的代码:
nonce=1
API_KEY = "0B02AD5AF57854184D68D3D1D4D980F9"
API_SECRET = "89b20f882220b5dc6feeb33253c25ba3"
Body=paste('method=getInfo&nonce=',nonce, sep="")
sign = hmac(API_SECRET, Body, algo="sha512")
title=add_headers('Content-type'='application/x-www-form-urlencoded', Key = API_KEY, Sign = sign)
rep=POST('https://yobit.net/tapi', body=Body, headers=title, encode='form')
nonce=nonce+1来自服务器的响应:
"{\"success\":0,\"error\":\"invalid key, sign, method or nonce\"}"谢谢你帮忙!
发布于 2018-04-12 10:43:33
这是我在节点js及其工作中完成的。
const crypto = require("crypto");
var apikey = 'apikey';
var secret = 'secret';
var signature = "method=getInfo&nonce="+ nonce;
console.log(signature);
var hmacsignature = crypto.createHmac('sha512', secret).update( signature ).digest('hex');
var headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Key': apikey,
'Sign': hmacsignature
};
var options = {
url: 'https://yobit.net/tapi',
method: 'POST',
body: signature,
headers: headers
}
console.log(options);
request1(options, function (error, response, body) {
res.send(body);
});https://stackoverflow.com/questions/49040333
复制相似问题