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.
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:
$config['appId'] = 'APP_ID_HERE';
$config['secret'] = 'SECRET_HERE';
And thats it. Try accessing domain.com/welcome/login (localhost if testing locally).
Few things to double check:
- Your FB application is not on Sandbox mode.
- Your website domain (or localhost if testing locally) is listed in app domains.
- Website with Facebook Login is enabled and pointed to your domain.
- App type is set to Web under advance settings.
- Client OAuth Login is enabled under advance settings.