开发者

How to make a HTTPS call from inside a Rails controller

开发者 https://www.devze.com 2023-03-31 16:00 出处:网络
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);

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

精彩评论

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