我正在为BTC制作XMLHttpRequest - E. API文档可以在这里看到:https://btc-e.com/api/documentation
var apiKey;
var apiSec;
var response;
var nonce;
var sign;
function signMessage() {
nonce = (new Date()).getTime().toString();
var hash = CryptoJS.HmacSHA512("?method=getInfo&nonce=" + nonce, apiSec);
sign = hash.toString(CryptoJS.enc.Hex);
}
function getPrice() {
var req = new XMLHttpRequest();
req.open("POST","https://btc-e.com/tapi", false);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Key", apiKey);
req.setRequestHeader("Sign", sign);
req.send("method=getInfo&nonce=" + nonce);
req.onload = function() {
response = JSON.parse(req.responseText);
};
}
signMessage();
getPrice();
console.log(responce);
似乎哈希正确完成或者至少得到正确的字符串。服务器响应:{“成功”:0,“错误”:“nonce参数无效;按键:0,您发送:1389814528941”}
已经挣扎了几个小时,无法弄清楚出了什么问题。