Skip to content

Facebook API client

tigerlily edited this page Sep 14, 2010 · 3 revisions

The request

The quickly way to call a Facebook API method :


  require 'faceb'
  FaceB.call('api-key', 'secret-key', 'users.getInfo', :fields => 'name', :uids => 123456)

If you want to call many methods it can be a good way to use a persistant session :


  require 'faceb'
  FaceB.new('api-key', 'secret-key')
  FaceB.session.call('users.getInfo', :fields => 'name', :uids => 123456)
  FaceB.session.call('fql.query', :query => 'SELECT first_name FROM user WHERE uid=123456')

And you can also use the other syntax :


  require 'faceb'
  FaceB.new('api-key', 'secret-key')
  FaceB.session.users.getInfo(:fields => 'name', :uids => 123456)
  FaceB.session.fql.query(:query => 'SELECT first_name FROM user WHERE uid=123456')

You can reset the persistent session at any time by calling the `reset!` method :


  FaceB.session.reset!

Clone this wiki locally