# Examples: # client = HGet.new("http://graph.facebook.com/USERNAME") # client.request # returns a Net::HTTPFound instance, with this you can see the status, headers and the body # Supports Https requests # HGet.new("https://graph.facebook.com/USERNAME?access_token=YOUR_ACCESS_TOKEN") require "net/https" require "uri" class HGet attr_reader :url, :response def initialize(url) @url = url end def https? !(url.match(/https:\/\//).nil?) end def uri @uri ||= URI.parse(@url) end def request @response ||= http.request(Net::HTTP::Get.new(uri.request_uri)) end def http @http ||= begin client = Net::HTTP.new(uri.host, uri.port) if https? client.verify_mode = OpenSSL::SSL::VERIFY_NONE client.use_ssl = true end client end end end