New Facebook Connect Library For CodeIgniter Released

-CodeIgniter Logo-If you’ve spoken to me about development at any point in the past few months, you’d know I’ve become a big fan of CodeIgniter for quick application development in PHP. Any regular programmer will always look for ways to save time during the development process. If you happen to be developing a Facebook Connect enabled site, then a Facebook Connect library can help save some time. Thankfully Elliot Haughin has done just that for CodeIgniter developers.

Last week Elliot released an extremely useful Facebook Connect CodeIgniter library that will get you up and running in under 5 minutes. I tested out the library this morning and it’s extremely useful. While I’ve implemented the widely used FB_Controller (found here) for Facebook platform applications, I haven’t implemented Connect with CodeIgniter prior to this morning. In 7 quick steps you can have a demo Facebook Connect enabled application up and running.

The core component of the code is the Facebook_connect class which enables you to quickly see if a Facebook user is logged in by calling a few quick lines of code from within one of your controller functions:

$this->load->library('facebook_connect');

$data = array(
	'user'		=> $this->facebook_connect->user,
        'user_id'	        => $this->facebook_connect->user_id
	);

If you then want to make any API calls you can simply call the api client functions. For example to get a user’s events you would then make the following call:

$events = $this->facebook_connect->client->events_get($data['user_id']);

One downside of this feature is that it’s not directly integrated into CodeIgniter’s session handling library but a few tweaks could integrate it pretty easily. As I’m in the process of building a few Facebook Connect enabled features on this site, this library will most definitely come in handy. The version released by Elliot is extremely simple and it works. If you are also implementing Facebook Connect within a CodeIgniter application, go check out Ellion Haughin’s library.