{ Hi! I'm Mike }
I'm a core developer with The Horde Project and a founding parter of Horde LLC - the company behind the world's most flexible groupware platform. This is my personal blog full of random thoughts about development and life in general.
May 4, 2009

Integrating Horde with Facebook

Like most of the stuff I work on, this one started out as a personal "wouldn't it be cool". I wanted to add a block on my portal that would allow me to quickly update my Facebook status, while seeing the most recent status updates of my friends without having to actually login to Facebook. I started by looking at the official Facebook PHP Client library, but wasn't happy with it's code structure, and the quality of the code wasn't really up to my standards, so I decided to completely rewrite it. The result is Horde_Service_Facebook and is available only on the Horde 4 development line, from the horde-hatchery git repository.

In addition to the new library, I've also started to add some integration points in Horde for users to interact with Facebook. The first such integration point is the Facebook block - which allows the user set their status, and see the most recent status updates.

Next up was an attempt to scratch an itch that another Horde developer had. He wanted to fill in missing email addresses in his Turba address book from his friends in Facebook. Unfortunately, I quickly found out that Facebook does not allow applications to obtain a user's email address. Well, actually, it will give you a proxied email address, but only if the user whose email you want has added your application and given it permission to get the proxied address. Not helpful at all for our purposes. I continued on with the Turba integration anyway, and the result is a Facebook driver for Turba that does provide at least some useful information, such as the friend's birthday - which can then be displayed in the user's Kronolith calendar.

The most recent integration point was made easier to implement thanks to the just released Open Streams API. Ansel now has initial support for automatically posting to the user's Facebook stream after images are uploaded to any of the user's public galleries. A small thumbnail of up to 5 images (linked to the Ansel view for that image) will be shown on the stream, along with the name of the gallery. The new Streams.publish method removes the requirement to create templates (and thus have to manage them) like we would have to do with the older PublishUserAction method.  Eventually, there will probably be user prefs in Ansel to allow/disallow such automatic posting either per gallery or per upload.

Setting up the integration is not too difficult, and involves creating a new Web Application on Facebook.  You will need to provide Facebook with what they call the Canvas Callback URL. This should be set to the URL of the horde/services/facebook.php page on your Horde server. This is the page that Facebook will redirect and post values back to during each user's initial application authentication.  Next, you will need to set the API Key and Application Secret in Horde's configuration. This is done on Horde's API Keys configuration tab.

That's it. Now each user can visit his or her Facebook Integration Options section of their user preferences and authorize the application as well as some of the permissions it will require.

 Keep in mind that this is still very much bleeding edge development code, and as such may still contain bugs and/or missing features. Comments and feedback are always welcome...