How to make a HTTPS call from inside a Rails controller
I need to access the Facebook graph api as follows:
$request_content = json_decode(file_get_contents("https:开发者_StackOverflow//graph.facebook.com/$request_id?$app_token"), TRUE);
How can I do this inside a Rails controller?
(The above is from php)
require 'net/http'
fb = Net::HTTP.get_response(URI.parse("https://graph.facebook.com/#{request_id}?#{app_token}")).body
request_content = ActiveSupport::JSON.decode(fb)
Not tested, but try something like this:
require 'net/http'
request_content = Net::HTTP.get_response(URI.parse("https://graph.facebook.com/#{request_id}?#{app_token}")).body
精彩评论