开发者

Ruby on Rails and facebook

开发者 https://www.devze.com 2023-04-09 03:33 出处:网络
I am trying to write a code in ruby on rails that would go into facebook and pull out data to populate my database based on key words that I manually add inside the code. Anyone has done something sim

I am trying to write a code in ruby on rails that would go into facebook and pull out data to populate my database based on key words that I manually add inside the code. Anyone has done something similar or can help开发者_如何学Python me with it by pointing me towards the right direction? Also I need the code to stay "alive" after the first run in order to update my site automatically. I've looked for a fb API but i couldn't find anything.

Thanks, Crematorio


The Facebook Graph API is what you would use to pull out data, typically the feed. As for Ruby on Rails, many ways to interact with the FB Graph, but I think the Koala gem is your ticket: https://github.com/arsduo/koala

You would need to set up an application at the FB Developers site, then pass the ID/secret to authenticate via Oauth. I use the following to pull wall feed, this little bit might get you started...

oauth = Koala::Facebook::OAuth.new('app ID here', 'app secret here', 'website/project url')
graph = Koala::Facebook::GraphAPI.new(oauth.get_app_access_token)
feed = graph.get_connections("facebook username here", "feed")
@facebook_feed = ActiveSupport::JSON.decode(feed.to_json)

Adapt this however you like, what I would probably do is a rake task that checks the results of @facebook_feed and processes them based on criteria, keywords, etc.

0

精彩评论

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

关注公众号