我需要访问Facebook图表api,如下所示:
$request_content = json_decode(file_get_contents("https://graph.facebook.com/$request_id?$app_token"), TRUE);
如何在Rails控制器中执行此操作?
(以上是来自php)
答案 0 :(得分:0)
未经测试,但尝试这样的事情:
require 'net/http'
request_content = Net::HTTP.get_response(URI.parse("https://graph.facebook.com/#{request_id}?#{app_token}")).body
答案 1 :(得分:0)
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)