开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜