var keys = {
'api': 'APIキー',
'secret': 'secretキー'
};
function get_nonce(){
return (new Date().getTime() / 1000).toFixed(0);
}
function toHexString(data) {
return data.map(function(e) {
return ('00' + (e & 0xFF).toString(16)).slice(-2);
}).join("");
}
function create_postdata(keys, body){
var sign = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_512, body, keys.secret);
return {
'method': 'post',
'headers': {
'sign': toHexString(sign),
'key': keys.api
},
'payload': body
};
}
function EntryPoint() {
var body= 'method=get_info&nonce=' + get_nonce();
Logger.log(body);
var post_data = create_postdata(keys, body);
Logger.log(post_data);
const endpoint = 'https://api.zaif.jp/tapi';
var response = UrlFetchApp.fetch(endpoint, post_data);
Logger.log("#############################");
Logger.log(response);
Logger.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Logger.log(response.getContentText());
}
Created
April 7, 2018 12:23
-
-
Save umyuu/10c6bb7d1c7e5bcf75c9ca191e3dcabb to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
◇参考情報
Zaif api document v1.1.1 ドキュメント トレードAPI 共通情報