开发者

Facebook Graph API call without any gem

Is it possible to use just Rails (without any gem) to interact with Facebook's Graph API?

Can you provide an example on how to do that and get only the JSON respond back? (with or w开发者_运维技巧ithout access_token)

I think I have to use Net::HTTP or something similar to curl in PHP?

Thanks


Depends what you mean by 'interact with'. To simply retrieve a Facebook Graph URL, you can use:

  require 'open-uri'
  file = open("https://graph.facebook.com/19292868552")
  file.read

To parse the JSON,

  require 'json'
  JSON.parse()

There are a few different HTTP libraries though, and a few different JSON ones - so look around before settling on a solution. Or use one of the gems that abstract away some of the Facebook Graph API calls.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜