A ruby wrapper for the new facebook graph api
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
facebook-stub @ d11eb24
lib
spec
.gitignore
.gitmodules
Gemfile
Rakefile
Readme.md
build.md
open_graph.gemspec

Readme.md

OpenGraph

A ruby wrapper for the new facebook graph api

Ruby

How to build this gem

git clone ... git submodule --init gem build open_graph.gemspec

Configuration

Gemfile

gem 'open_graph'

config/facebook.yml

development:
  appid: YOUR_APP_ID
  key: YOUR_APP_KEY
  secret: YOUR_APP_SECRET
production:
  ...

You'll have access to the config by OpenGraph.config[:key]

Initialization

ApplicationController::Base has access to fb_open_graph

fb_open_graph automatically parses and validates your facebook cookie like a boss.

API

fb_open_graph.valid?

will return true or false if you have a valid session.

fb_open_graph.use_manual_session!(new_facebook_id, new_access_token)

will force it to not use the cookie, but use your facebook_id and_access_token instead

Get Calls

All get calls take an options hash, but not all get calls will use them. The calls which accept paging can take (:limit, :offset, :until, and :since).

fb_open_graph.info

will return a hash of information. possible keys may be [:name, :email, :first_name, :middle_name, :last_name, :gender, :id, :locale :religion, :bio, :hometown, :birthday], etc. info[:location] returns a hash of [:name, :city, :zip, :country, :id, :state]

fb_open_graph.picture(:type => (square|small|large))

will return the a hash of {:content_type => 'image/jpeg', :image => actual_image_data}.

Other Get calls

friends, news_feed, profile_feed, likes, movies, music, books, notes, photo_tags, photo_albums, video_tags, video_uploads, events, groups, checkins

Publish Calls

UNDER CONSTRUCTION FOR BETTER PUBLIC API

All methods take options specified in the facebook api such as Post

publish!, note!, link!, event!, album!, checkin!

Permissions

fb_open_graph.has_permissions?(*permission_names_comma_separated)

will return true or false

JavaScript

You'll want something that looks like this in your view:

if Rails.env.test?
  include_facebook_stub
else
  javascript_include_tag '//connect.facebook.net/en_US/all.js#xfbml=1'
end