Last Modified 2009-02-28 by Michael Rubinsky


Documentation on the Horde_Service_Facebook package.

General Info

This library is a general purpose client library for interacting with Facebook's API. It's primary purpose is to allow other Horde applications to both receive and send content to Facebook. Before using this library you will need to properly set up a web application with Facebook. The details to do this are beyond the scope of this entry. You can find specific instructions at http://developers.facebook.com/get_started.php?tab=tutorial. You will need to know the application api key as well as the application's secret key. You will also need a callback page that Facebook will redirect to after successful authentication events (see below).

Example Code to create an instance of Horde_Service_Facebook:

$key = 'xxx';

$secret = 'xxx';

// We require a client and request object. We could also

// pass a logger if desired. If you have a Horde_Controller

// instance, you could pass that as 'controller' instead of

// the http_request.

$context = array('http_client' => new Horde_Http_Client(),

                 'http_request' => new Horde_Controller_Request_Http());

$facebook = new Horde_Service_Facebook($key, $secret, $context);


Authenticating a Facebook application from another web application is not a simple task. The user needs to first be logged into Facebook, then authorize your application to interact with the user's Facebook profile. In addition, in order to allow the application to interact with Facebook without having to redirect the user to a login for each new session, you will need an infinite session. There are also multiple other 'extended permissions' that Facebook requires to be approved individually. It is up to the client application to deal with these requirements. Here is some sample code demonstrating the authentication process.