简体   繁体   中英

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 without 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM