Which Ruby Gems Support the Facebook API

Which Ruby gems support the Facebook API?

The Koala Gem is the way to go.

These Railscasts from July will tell you all you need to know about interacting with the Social Graph in Ruby and in Rails (both are paid episodes):

#361: Facebook Graph API: Learn how to use the Facebook Graph API with the Koala gem to fetch data from Facebook and post content through a user. Here I delve into permissions, error handling, and more.

#363: Facebook Open Graph: This episode builds on last week's episodes and shows how to integrate Facebook further through the Open Graph protocol. You will also learn how to tunnel your local server and move Facebook communication into a background process.

Facebook gem for Ruby on Rails

i'm using koala - works with OAuth authentication and Facebook Graph API. Didn't have any serious problems with it, and it's pretty well documented (with examples) on github

Facebook gem for Rails app

koala seems to be popular choice for the task you specified.

Koala is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the REST API, realtime updates, test users, and OAuth validation.

https://github.com/arsduo/koala

Documentation is here:

https://github.com/arsduo/koala/wiki/Graph-API

Posting to Facebook Page through API as the page (with admin rights)

Well, definitely the gem you are looking for is Koala.

Update:

As it seems, you are having some problem setting the actual configuration of Koala gem. Let's go through every step.

You need to setup a new Koala::Facebook::API. Despite of being a horrible name, this is really the connection to your profile user. To set up this you need to access the Facebook Explorer and click Get Access Token button (make sure you are logged with the account you wanna post message's to). just copy that access token.

@user = Koala::Facebook::API.new(access_token)

Use that access_token to set this new @user. Now whenever you mention "me" in any Graph API request on a @user, you'll be mentioning this user (@user) as the target for that request. "me" is just the facebook ID for the user itself.

The final step is just to post to your user's feed page.

@user.put_connections("me", "feed", :message => "I am writing on my wall!")

So, if you want to post as a page on your wall. You can do so by

@user = Koala::Facebook::API.new(access_token)
page_access_token = @user.get_connections('me', 'accounts').first['access_token'] #this gets the users first page.
@page = Koala::Facebook::API.new(page_access_token)
@page.put_connections(user_id, "feed", :message => "Page writting to user's wall!")

Just go to graph.facebook.com/user_path and get the your_ID.



Related Topics



Leave a reply



Submit