Integrating Facebook PHP SDK is not that hard, it only takes few minutes to do that. But its completely different story when you are integrating it with CodeIgniter.

Thats because Facebook PHP SDK takes input from $_REQUEST variable while CodeIgniter purges the $_REQUEST variable for security reasons. Other important reason is theres no dedicated library available for it (while there are few available for Twitter) and there is vast range of solutions if you search for it but no proper solution (atleast I didn’t find one).

So I decided to create one and worked on it last week.

Facebook PHP SDK for CodeIgniter on Github

There are four folders config, controllers, libraries and views. All you need to do is, copy these folders to application folder of your CI installation.

Then replace your facebook application id and secret in facebook.php file under config folder:

And thats it. Try accessing (localhost if testing locally).


Few things to double check:

  1. Your FB application is not on Sandbox mode.
  2. Your website domain (or localhost if testing locally) is listed in app domains.
  3. Website with Facebook Login is enabled and pointed to your domain.
  4. App type is set to Web under advance settings.
  5. Client OAuth Login is enabled under advance settings.