Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


The Awexome Labs client library for accessing and manipulating the Facebook OpenGraph in ruby.

DoesOpenGraph is designed to be a paper-thin library for accessing and manipulating data on the Facebook Open Graph. It does not provide a high number of task or object- specific integration points, instead relying on your application to discern the type and content of each Node you access.

Likewise, the library is not configured with a YAML file, but is instead initialized when you instantiate an object of the GraphAPI. This makes the library ideal for use in ruby applications and scripts of all types, not just in rails.

If you are interested in full configuration for, say, a rails app, you can pair up with DoesFacebook, our library for parsing signed requests from Facebook and providing convenience methods to controllers and views.


To install the gem, do the usual:

gem install doesopengraph

If you plan on using DoesOpenGraph in a project with a Gemfile:

gem "doesopengraph"

You can live on the edge, too, if you like:

gem "doesopengraph", :git=>"git://"

Example Usage

Using DoesOpenGraph is easy. You can access public content without an access token. To do so, just spin up a non-private API instance and go:

include DoesOpenGraph
api =
 => #<DoesOpenGraph::GraphAPI:0x00000100a13320 @access_token=nil> 

node = api.node("philadelphiaflyers")
 => #<DoesOpenGraph::GraphNode:0x00000100a055e0 @content={"id"=>"87169796810", "name"=>"Philadelphia Flyers", "picture"=>"", "link"=>"", "category"=>"Professional sports team", "website"=>"\n\n\n", "username"=>"philadelphiaflyers", "location"=>{"street"=>"Wells Fargo Center, 3601 South Broad St.", "city"=>"Philadelphia", "state"=>"PA", "country"=>"United States", "zip"=>"19148"}, "phone"=>"215.218.PUCK (7825)", "affiliation"=>"NHL", "likes"=>446371}, @api=#<DoesOpenGraph::GraphAPI:0x00000100a13320 @access_token=nil>>

You'll see that accessing a public page via the GraphAPI will return a GraphNode object containing attributes from the graph document. You can access these attributes directly:

 => 446374 
 => "NHL"
 => "215.218.PUCK (7825)" 
 => "Professional sports team" 
 => ""

Not bad! You may also notice that the returned GraphNode object contains a reference to the GraphAPI object that was used to access it. This allows you to run a reload on the node just as if it were an ActiveRecord object. Reloading will pull the latest content from the Open Graph and update your local object. So if someone had come along and liked or unliked the page in the time we'd been playing around, we'd see the increase or decrease:

 => [updated GraphNode object returned]
 => 446373        # Whoops! One less fan! :-(

Load Node Metadata and Connections

For any node object you've pulled from the graph, you can ask it what it's capable of providing. This allows you to see all of the fancy bits that may extend or be attached to the user, page, or object you're looking at. These are called “connections” in the graph.

Not sure what connections are at your disposal? Ask!

=> #<DoesOpenGraph::GraphNode:0x000001009a49c0 @content={"id"=>"87169796810", "name"=>"Philadelphia Flyers", "picture"=>"", "link"=>"", "category"=>"Professional sports team", "website"=>"\n\n\n", "username"=>"philadelphiaflyers", "location"=>{"street"=>"Wells Fargo Center, 3601 South Broad St.", "city"=>"Philadelphia", "state"=>"PA", "country"=>"United States", "zip"=>"19148"}, "phone"=>"215.218.PUCK (7825)", "affiliation"=>"NHL", "likes"=>446373, "metadata"=>{"connections"=>{"feed"=>"", "posts"=>"", "tagged"=>"", "statuses"=>"", "links"=>"", "notes"=>"", "photos"=>"", "albums"=>"", "events"=>"", "videos"=>""}, "fields"=>[{"name"=>"id", "description"=>"The Page's ID. Publicly available. A JSON string."}, {"name"=>"name", "description"=>"The Page's name. Publicly available. A JSON string."}, {"name"=>"category", "description"=>"The Page's category. Publicly available. A JSON string."}, {"name"=>"likes", "description"=>"\\* The number of users who like the Page. Publicly available. A JSON number."}]}, "type"=>"page"}, @api=#<DoesOpenGraph::GraphAPI:0x00000100a13320 @access_token=nil>>

Perhaps that's too much to read through, but the key point is that introspecting a node returns the very same node, but includes the all-important metadata attribute, which you can pull available connections from:

=> {"feed"=>"", "posts"=>"", "tagged"=>"", "statuses"=>"", "links"=>"", "notes"=>"", "photos"=>"", "albums"=>"", "events"=>"", "videos"=>""}

Curious as to the public feed of the node object? Grab it like so:

node = api.node("philadelphiaflyers", "feed")
=> # A huge list of feed posts you can play with
node = api.node("philadelphiaflyers", "photos")
=> # Likewise huge list of photos to do fun things with

And that's pretty much it.

Private and Privileged Usage

You can do more than read and reload objects on the graph, however. It's easy to post new connection pieces, remove content from the graph, and remove and alter connections to specific nodes on the Open Graph.

To do it, you'll need an OAuth access token. Your application can handle this by following any of the Facebook methods documented at

Once you have an access token for a particular user, page, or node, instantiate a special GraphAPI object with it for easy-access:


With a privileged API client, you can now expose the following methods of the API:

api.node()    # just like before, but with more info; aliased as api.get()
api.update()  # alter and add data; aliased as
api.delete()  # delete something from the graph (a post, connection, or node)  # search the entire open graph

Explore and enjoy!

Copyright (C) 2011-12 by Awexome Labs, LLC


The Awexome Labs client library for accessing and manipulating the Facebook OpenGraph in ruby




No packages published