Reputation: 31
This should be simple, given the public nature of the data, but for some reason my Ruby script is timing out on making the request.
The URL is http://mtgox.com/api/1/BTCGBP/ticker - works fine in browsers, and returns the expected JSON.
require 'net/https'
require 'uri'
uri = URI.parse('https://mtgox.com/api/1/BTCGBP/ticker')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
resp, response = http.post(uri.request_uri, nil)
This, however, returns the Timeout::Error: execution expired exception (every time) from the same box. I'm probably missing something really obvious; can anyone help?
Thanks
Upvotes: 2
Views: 391
Reputation: 572
I tried your code in my environment and everything was ok. Can you write something more about this error, in which line it happened etc. ? And are you sure to use POST verb (RESTful) ? What do you want to do ? I modified your code:
require 'net/https'
require 'uri'
uri = URI.parse('https://mtgox.com/api/1/BTCGBP/ticker')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
resp = http.get(uri.request_uri)
puts resp.body
I use GET verb and I got JSON.
Upvotes: 3