开发者

Simple use of facebook graph with rails 3

I want to get the user content after he sign in with the login button

therefore I need to convert this code from php to rails 3

$user = json_decode(file_get_contents(
'https://graph.facebook.com/me?access_token=' .
$cookie['access_token']));

I don't want to use any gem like httparty.

I tried this code with no success

uri = URI.parse(URI.encode('https://graph.facebook.com/me?access_token=' + fbhash['access_token']))
    require 'net/http'
    content = Net::HTTP.get(uri)
    content = ActiveSupport::JSON.decode(content)

fbhash['access_token'] contain the right access_token for the user

the e开发者_JAVA百科rror message I get is

end of file reached


I ended up using open-uri

content = open(URI.encode('https://graph.facebook.com/me?access_token=' + fbhash['access_token']))
content = ActiveSupport::JSON.decode(content)

works great

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜