Question

I am having trouble to get anything using https.

I can't fetch anything like:

curl -k https://graph.facebook.com

or

uri = URI('https://graph.facebook.com/davidarturo')
Net::HTTP.get(uri)

I get:

error: EOFError: end of file reached

Also there is no luck with httparty and https

Was it helpful?

Solution

As you use 'https' protocol, you must explicitly tell about it in case of using net/http library:

require 'net/http'

uri = URI('https://graph.facebook.com/davidarturo')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'

http.start do |h|
  response = h.request Net::HTTP::Get.new(uri.request_uri)
  puts response.body if Net::HTTPSuccess
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top