Cannot get anything in https protocol with curl, httparty or net::http

无人久伴 提交于 2019-12-02 07:05:11

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!