Closed Popcaughan closed 6 years ago
updated, please try
No joy, sorry.
SyntaxError: Unexpected token: P (line 31, file "Stamp")
When I Logger.log(response); the log says "POST Only Endpoint"
When I Logger.log(options) the log says: "method=post, payload=key=MY API KEY&signature=94,113,68,-68,28,72,-1,-3,41,33,-2,58,-102,-113,-95,-71,47,25,-55,-34,95,-33,-125,28,22,-91,-61,89,103,20,-62,102&nonce=13 digit number here
I have changed some of the numbers in the signature.
When I tried to hire a guy on Fiverr to do this for me he said that "bitstamp and cryptopia use another kind of algorithm with is not supported on google scripts for now" so maybe this script needs to look more like the cryptopia one?
Not good for signature it' should be HEX number. I need to open an account and doing more test before post code
Finally found (I hope because not yet an account) Please try again (V0.3) Thanks for your support
Still the same, sorry:
Options logs as: {method=post, payload=key=API KEY &signature=20FA4834E564A56CCBC6E3A94D7D6391D123BAE25984378581D76172AF587F03&nonce=1516496033795, muteHttpExceptions=true} Response logs as: POST Only Endpoint
And the script gives the error: SyntaxError: Unexpected token: P
Hi, have you had a chance to look at this? I can provide you with API details if you need some to test with.
Hi, no way at this moment. found this : https://github.com/blacksun1/google-scripts-bitstamp-api need to work on it
updated, just changed var url = "http://www.bitstamp.net/api/v2/balance/"
by var url = "http://www.bitstamp.net/api/balance/"
please try again
No joy. Options logs as: {method=post, payload=key=MYAPIKEYHERE&signature=51D0F5FDAF1234567898765432142233949A680CFF0C73C19414EEF&nonce=1518207217, muteHttpExceptions=true}
Response logs as: {"error": "Missing key, signature and nonce parameters"}
I'll have a look at that other script and maybe see if I can pay someone on fiverr to crack this one for us.
That script requires crypto-js's hmac 256 api, but the link provided on that git doesn't work anymore so I'm not sure where to get that from. Would be good if it worked with the same jsSHA that you're using but this line throws an error:
return CryptoJS.HmacSHA256(message, this.secret).toString().toUpperCase();
I think we are really near a solution, the problem come from the end of the code
var url = "http://www.bitstamp.net/api/balance/"
cb = "key=" + key + "&signature=" + signature + "&nonce=" + nonce;
//var options = { method: 'post' };
var options = {
"method" : "post",
"payload": cb,
"muteHttpExceptions" : true
};
var response = UrlFetchApp.fetch (url, options);
var data = JSON.parse(response.getContentText());
updated try again
No sorry... The new code still gives "POST Only Endpoint"
Swapping the url to http://www.bitstamp.net/api/balance/ gives {"error": "Missing key, signature and nonce parameters"}
Sorry!
I fixed the issue @Popcorn2018 & @ManuCart (see link).
Also added conversion to correct input format for main.js.
Well done! Merged Hope found the solution. Thanks @jelbazi
Thanks for looking at this one, I gave it a go and got the following error:
Request failed for http://www.bitstamp.net/api/v2/balance/?key=CORRECT API KEY WAS HERE &signature=LONG STRING SIGNATURE WAS HERE&nonce=1516333128 returned code 400. Truncated server response: POST Only Endpoint (use muteHttpExceptions option to examine full response)
Happy to help test this and here's my (probably terrible) string manipulation code ready to go to pull the results into an array: function Bitstamp() { //insert api code here var data = JSON.parse(response.getContentText()); var json1 = JSON.stringify(data);
parseStampPrices(json1); }
function parseStampPrices(textString ){
var stringLength = textString.length;
if(stringLength > 80){
}
}
// This method is used as part of parsing the Bitstamp info function nthIndex(str, pat, n){ var L= str.length, i= -1; while(n-- && i++<L){ i= str.indexOf(pat, i); if (i < 0) break; } return i; }