GithubHelp home page GithubHelp logo

fbgraph's Introduction

FBGRaph (0.1.4)

Facebook Open Graph API Gem.

Resources

Installation

gem install fbgraph

Be sure to require it

require "fbgraph"

or add this line into Gemfile for Rails 3

gem "fbgraph"

Example Apps

Rails 3 Example

Usage

FBGraph supports the most (no analytics yet) features of Facebook Open Graph API: developers.facebook.com/docs/reference/api/

Initialization

Without a token (for authorization)

client = FBGraph::Client.new(:client_id => 'client_id',:secret_id =>'secret_id')

With a token

client = FBGraph::Client.new(:client_id => 'client_id',:secret_id =>'secret_id' ,:token => token)

All methods are chainable

Examples:

client.selection.me.photos.until(Time.now.to_s).since(3.days.ago).limit(10).info client.selection.user('id').videos.offset(10).info client.search.query('q').on('users').limit(20).info

Rails config file

TODO

Authorization

client.authorization.authorize_url

returns the authorize url

redirect_to client.authorization.authorize_url(:redirect_uri => callback_url , :scope => 'email,user_photos,friends_photos')

client.authorization.process_callback

process the callback and returns the access token

access_token = client.authorization.process_callback(params[:code], :redirect_uri => callback_url)

Exchange Sessions

TODO

Canvas

TODO

Selection

Accessing objects with connection types.

All objects and their connections can be accesed

Examples:

client.selection.me.home.info! client.selection.user('id').photos.info! client.selection.photo('id').comments.info! client.selection.page('id').info!

Also you can get results of more than 1 objects

Example:

client.selection.user([id1,id2,id3]).info!

client.selection.info!

request with GET for information and return the response parsed with JSON. You can disable the parsing passing false as a first and unique parameter

user_info = client.selection.me.info!

Publishing

client.selection.publish!

request with POST for publishing and return the response parsed with JSON. You can disable the parsing passing false as a first and unique parameter

client.selection.post('id').comments.params(:message => 'comment test').publish!

OR

client.selection.post('id').comments.publish!(:message => 'comment test')

Deletion

client.selection.delete!

request with DELETE for deletion and return the response parsed with JSON. You can disable the parsing passing false as a first and unique parameter

client.selection.post('id').delete!

Picture

client.selection.picture

return the url of the object picture

client.selection.me.picture

Paging

client.selection.limit

client.selection.me.photos.limit(3).info!

client.selection.offset

client.selection.me.photos.offset(10).info!

client.selection.until

client.selection.me.photos.until(Time.now.to_s).info!

client.selection.since

client.selection.me.photos.since(3.days.ago).info!

Search

client.search.query(‘query’).info!

Get the search results

results = client.search.query('facebook').info!

client.search.query(‘query’)on(‘type’).info!

Get the search results by type

results = client.search.query('facebook').on('home').info!

RealTime Updates

client.realtime.user

client.realtime.permissions

client.realtime.errors

Set the object to be subscribed, modified or unsubscribed

client.realtime.fields(‘email,picture’)

Set the objects fields

client.realtime.callback_url(url)

Set the callback url

client.realtime.verify_token(token)

Set the verify token (optional)

client.realtime.subscribe!

Send the request for add/modify a subscription for realtime Updates.

Examples:

results = client.realtime.user.fields('email,picture').callback_url(url).verify_token('token').subscribe! results = client.realtime.permissions.fields('read_stream').callback_url(url).subscribe!

If you want delete a subscirpition, you can use the delete! method.

Examples:

results = client.realtime.user.delete!

Analytics

TODO

Advanced

not documented yet

Contributions

Just do a pull request with the repo in sync.

Contributors List

Victor Costan

Mark Bates

Florent Guilleux

Jan De Poorter

Thilo-Alexander Ginkel

fbgraph's People

Contributors

ginkel avatar joren avatar markbates avatar nsanta avatar pgericson avatar pwnall avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.