Skip to content
Facebook Open Graph Library
Find file
Latest commit 752b90b Mar 20, 2014 @mmangino Merge pull request #149 from rrivas/additional-friend-permissions
Add birthday, location, and relationships permissions for friends
Failed to load latest commit information.
lib Add birthday, location, and relationships permissions for friends Mar 20, 2014
.gitignore Ignore Gemfile.lock and others Aug 16, 2011
.rspec Add rake as a development dependency Aug 16, 2011
COPYING.rdoc Add license and readme Apr 30, 2010
Changelog bump again Sep 14, 2012
Gemfile Added Gemfile and development dependencies, to test gem Jul 27, 2011
Rakefile Opt-in for testing with rubygems-test Aug 16, 2011
Readme Add info to readme for creating photos Oct 12, 2011
Todo.txt Add app_request and fix the capitalization of fql names Feb 1, 2011
init.rb use HTTMultiParty to support file upload Oct 12, 2011
mogli.gemspec Version bump Jan 3, 2014


The first version of a Facebook Open Graph Library for Ruby. Require HTTParty to function.

For documentation on the Open Graph Library, see:

Quick Start:

Add config.gem "mogli" to environment.rb

For Rails: create a controller like the following:

class OauthController < ApplicationController

  def new
    redirect_to authenticator.authorize_url(:scope => 'publish_stream', :display => 'page')
  def create    
    mogli_client = Mogli::Client.create_from_code_and_authenticator(params[:code],authenticator)
    redirect_to "/"
  def index
    redirect_to new_oauth_path and return unless session[:at]
    user = Mogli::User.find("me",[:at]))
    @user = user
    @posts = user.posts
  def authenticator
    @authenticator ||='client_id', 

with routes:

map.resource :oauth, :controller=>"oauth"
map.root :controller=>"oauth"
map.oauth_callback "/oauth/create", :controller=>"oauth", :action=>"create"

Viewing / should redirect you to the login page, and then redirect back to your app to show your recent posts

From the console, you can create a client with the stored access token:

require "rubygems"
require "mogli"
client ="your_access_token")

You can now fetch users with the client, for example:

myself  = Mogli::User.find("me",client)


mikemangino = Mogli::User.find(12451752,client)

When you fetch yourself, you can look at your posts and other information:


You can also fetch other objects by ID, for example:

album = Mogli::Album.find(99394368305)

If the object requires a client, just pass one in:

album = Mogli::Album.find(99394368305,client)

You can also upload photos using httmultiparty:
facebook_access_token = "..."
client ="me/photos", nil, {:source =>"myphoto.jpg")})


1) fork the repo
2) Add tests for a missing method, such as
3) implement missing method
4) send me a pull request.

Feel free to add missing associations if you see them as well. My goal is to get a readonly API in place first, and then move on to the read/write API


Something went wrong with that request. Please try again.