Clone or download
Pull request Compare This branch is 5 commits behind qoobaa:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


OpenSocial – REST/RPC and authentication wrappers

The OpenSocial modules provides wrapper functionality for REST and RPC HTTP requests to OpenSocial-compliant endpoints. The results of these calls are translated into helper objects, each representing a specific type of data that the calls are expected to return. Finally, the module provides helper functionality for verification of signed makeRequest calls.


This library operates using a set of wrappers around basic HTTP requests and authentication, including the following features:

  • Read-only REST support:

    r =
    person = r.send
    puts person.display_name
    # person is a Person object.
  • Read-only RPC support (with batch processing):

    r =
    r.add(:me =>
    r.add(:friends =>
    data = r.send
    # data contains two entries.
    # data[:me] is a Person object. 
    # data[:friends] is a Collection of Person objects, indexed by ID.
  • Automatic OAuth HMAC-SHA1 signing on outgoing requests:

    consumer_key = ''
    consumer_secret = 'uynAeXiWTisflWX99KU1D2q5'
    requestor = '03067092798963641994'
    c = => OpenSocial::Connection::ORKUT,
                                   :consumer_key => consumer_key,
                                   :consumer_secret => consumer_secret,
                                   :xoauth_requestor_id => requestor)
    r =
    person = r.send
  • Incoming signed makeRequest verification helper:

    class ExampleController < ApplicationController
      CONSUMER_KEY = '623061448914'
      CONSUMER_SECRET = 'uynAeXiWTisflWX99KU1D2q5'
      include OpenSocial::Auth
      before_filter :validate
      def return_private_data


The following gems and their dependencies are required by this client library:

  • oauth

  • json

  • rails (optional, for incoming signed makeRequest validation)

  • mocha (optional, for running tests)

Once you have the required gems installed, check out the project code from SVN, and copy opensocial.rb and opensocial/ into your application's path. Then add:

require 'opensocial'

in your code.

To generate docs:

rdoc * --main README

from the (tag/branch/trunk) root of the project directory.

To run tests:

rake test

from the (tag/branch/trunk) root of the project directory.

Learning More

Examples, current issues and feature requests, and the most up-to-date code are available on the project page.

Discussion of this client library and others takes place here.


If you'd like to contribute code to the project, check out this wiki page.