Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

facebookrb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

facebookrb

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= facebookrb

Facebookrb aims to be a lightweight yet fully featured client for the {Facebook API}[http://wiki.developers.facebook.com/index.php/API], drawing on the best features from existing Ruby Facebook libraries. The functions and features are intentionally kept simple, so you can spend your time reading the official Facebook documentation rather than learning how the code works.

== Installation

gem install facebookrb

== General Usage

The easiest way is to use the middleware. Put this in your config.ru, Sinatra application, or wherever you declare middleware:

require 'facebookrb'

use FacebookRb::Middleware, :api_key => "APIKEY", :secret => "SECRET"

This will create a Facebook API client, populate it with any parameters from Facebook, and store it in the Rack env for you.

fb = env['facebook.client']

Make a call using short or long format (thanks tmm1/sinbook for the short version)

user = fb.users.getInfo('uids' => '123235345', 'fields' => ['name', 'sex', 'religion'])
user = fb.call('users.getInfo', 'uids' => '123235345', 'fields' => ['name', 'sex', 'religion'])

This call parses the JSON from Facebook and returns the resulting objects (a Hash, Array, String, or Integer depending on how complex the JSON is). The raw text of the response is also available:

fb.call(...)
fb.last_response

If you received params from Facebook, and they are {valid}[http://wiki.developers.facebook.com/index.php/Verifying_The_Signature], then you can access them:

fb.params['user']
fb['user']  # Also works

The 'session_key' param will automatically be passed forward to any API calls if available.

== Options

The options for the middleware and the client are identical, and are values you get from Facebook:

:api_key, :secret, :canvas_url

== Features

=== Facebook Connect

The library supports reading parameters from cookies, so Connect support should be there (not thoroughly tested ATM).

=== {Batching}[http://wiki.developers.facebook.com/index.php/Using_Batching_API]

results = fb.batch do 
 fb.application.getPublicInfo(...)
 fb.users.getInfo(...)
end

results[0]  # => result for first call
results[1]  # => result for second call

== Potential Features

These would all be easy to add if anyone needs support for them.

== Acknowledgements

The code for this project was initially derived from:

FAQs

Package last updated on 05 Feb 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc