Author

Topic: Help with Javascript and Github Pages (Read 1755 times)

hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
March 11, 2014, 07:37:25 PM
#12
I'd go with gogodr's solution, it'll be the simplest for you - BUT ONLY IF you just request public ticker data, you should in NO CASE send private user-data (passwords ect...) through 3rd-party proxy-services.
If you want to read more about JSONP and how to evade the cross-domain issue for JSON-requests, you can take a look here: http://en.wikipedia.org/wiki/JSONP (or google for JSONP)
Thanks to gogodr, that should work just fine, and of course I'll only be using it for non-private information.

The only other thing to be careful of is that you're now putting yourself in the hands of whateverorigin: they could send back false or even malicious data. Not that I have any reason to suspect that they would, but it's just something to think about.

If you whant to make a site that would display API data from multiple exchanges and display it to the user use php better!

He could still be using PHP; he just wants the client to load the information instead of doing it on the server.
I really want to do as much as I can in javascript and will only resort to PHP as a last resort. Also, a MITM is no problem because all i'm fetching is ticker data. They can't really do anything with that and nothing important is going to be stored on the site anyways.
sr. member
Activity: 434
Merit: 250
March 11, 2014, 06:07:31 PM
#11
I'd go with gogodr's solution, it'll be the simplest for you - BUT ONLY IF you just request public ticker data, you should in NO CASE send private user-data (passwords ect...) through 3rd-party proxy-services.
If you want to read more about JSONP and how to evade the cross-domain issue for JSON-requests, you can take a look here: http://en.wikipedia.org/wiki/JSONP (or google for JSONP)
Thanks to gogodr, that should work just fine, and of course I'll only be using it for non-private information.

The only other thing to be careful of is that you're now putting yourself in the hands of whateverorigin: they could send back false or even malicious data. Not that I have any reason to suspect that they would, but it's just something to think about.

If you whant to make a site that would display API data from multiple exchanges and display it to the user use php better!

He could still be using PHP; he just wants the client to load the information instead of doing it on the server.
if that ever were to happen, they have their whole project open sourced. Anyone can take the source and make his own whateverorigin.
There are a couple of limitations though. you cant POST or GET parameters using whateverorigin.
member
Activity: 84
Merit: 10
March 11, 2014, 03:54:20 PM
#10
I'd go with gogodr's solution, it'll be the simplest for you - BUT ONLY IF you just request public ticker data, you should in NO CASE send private user-data (passwords ect...) through 3rd-party proxy-services.
If you want to read more about JSONP and how to evade the cross-domain issue for JSON-requests, you can take a look here: http://en.wikipedia.org/wiki/JSONP (or google for JSONP)
Thanks to gogodr, that should work just fine, and of course I'll only be using it for non-private information.

The only other thing to be careful of is that you're now putting yourself in the hands of whateverorigin: they could send back false or even malicious data. Not that I have any reason to suspect that they would, but it's just something to think about.

If you whant to make a site that would display API data from multiple exchanges and display it to the user use php better!

He could still be using PHP; he just wants the client to load the information instead of doing it on the server.
member
Activity: 112
Merit: 12
March 11, 2014, 01:43:32 PM
#9
If you whant to make a site that would display API data from multiple exchanges and display it to the user use php better!
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
March 10, 2014, 07:59:07 PM
#8
I'd go with gogodr's solution, it'll be the simplest for you - BUT ONLY IF you just request public ticker data, you should in NO CASE send private user-data (passwords ect...) through 3rd-party proxy-services.
If you want to read more about JSONP and how to evade the cross-domain issue for JSON-requests, you can take a look here: http://en.wikipedia.org/wiki/JSONP (or google for JSONP)
Thanks to gogodr, that should work just fine, and of course I'll only be using it for non-private information.
newbie
Activity: 55
Merit: 0
March 10, 2014, 04:34:28 PM
#7
I'd go with gogodr's solution, it'll be the simplest for you - BUT ONLY IF you just request public ticker data, you should in NO CASE send private user-data (passwords ect...) through 3rd-party proxy-services.
If you want to read more about JSONP and how to evade the cross-domain issue for JSON-requests, you can take a look here: http://en.wikipedia.org/wiki/JSONP (or google for JSONP)
sr. member
Activity: 434
Merit: 250
March 09, 2014, 11:54:02 PM
#6
I use a work around for your problem here:
http://btca.frikicorp.com/
I use whateverorigin, it bypasses the cross domain control with a clever trick (setting up a local proxy)
I use the btc-e api here, but you can get the idea

$.getJSON('http://whateverorigin.org/get?url=https://btc-e.com/api/2/btc_usd/ticker&callback=?', function(data){
       BTCBuy = JSON.parse(data.contents).ticker.buy;
       BTCSell = JSON.parse(data.contents).ticker.sell;
      });
member
Activity: 84
Merit: 10
March 09, 2014, 06:49:04 PM
#5
Like the error says, you're trying to make a cross-domain request, which it looks like bitstamp doesn't allow. You have a few options here, but I think the best one would just be to proxy the request through your servers. You can find some more info and code for doing that in PHP at these links:

http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-is-present-on-the-req
http://stackoverflow.com/questions/12683530/origin-http-localhost-is-not-allowed-by-access-control-allow-origin
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
March 09, 2014, 06:10:09 PM
#4
Are you authenticating with the bitstamp API properly? Not used it myself but the doc page says all requests need to be authenticated.  Or are you seeing a message specifically relating to limits?
I'm using the public part (https://www.bitstamp.net/api/ticker/) so it doesn't need authed per the docs. On my webpage with jQuery, I opened the console and did this:
Code:
var test = jQuery.getJSON("https://www.bitstamp.net/api/ticker/");
And got the error
Code:
XMLHttpRequest cannot load https://www.bitstamp.net/api/ticker/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rgbkey.github.io' is therefore not allowed access.

I would appreciate if anyone could tell me why this doesn't work. I can load the page fine from my web browser.
sr. member
Activity: 295
Merit: 250
March 09, 2014, 03:20:52 AM
#3
Are you authenticating with the bitstamp API properly? Not used it myself but the doc page says all requests need to be authenticated.  Or are you seeing a message specifically relating to limits?
member
Activity: 84
Merit: 10
March 08, 2014, 09:41:37 PM
#2
If you're using something like jQuery.get() then it's already sending it from the client IP.
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
March 08, 2014, 08:57:51 PM
#1
Hello, I was trying to make a site that would display API data from multiple exchanges and display it to the user as a learning project but when I went to actually use javascript to get the API data, my IP was blocked from Bitstamp's servers. I assume this is because someone on github pages went over the request limit and got the IP banned. Is there a way to make the javascript send the request from the client IP instead of the server so that the IP isn't blocked? Thanks!
Jump to: