How to implement facebook login into cakephp?

Step – 1 :  First of all , You have to create one developer account into facebook dveloper page like this : https://developers.facebook.com/apps.

Step – 2 : Then create the new App from the following button,

fb-1

 

Step – 3 : Then insert all the details about the,

fb-2

 

Step – 4 : From to create app, you have get the AppId and also Secret string, you get that both to use in your code.

Step – 5 : download the file facebook.zip which is the available plugin files you should extract this file in your app/plugin/directory like app/plugin/Facebook

Step – 6 : Use the following code ,in your config folder in config/facebook.php,

Facebook

/**
* Get an api_key and secret from facebook and fill in this content.
* save the file to app/Config/facebook.php
*/
$config = array(
‘Facebook’ => array(
‘appId’ => ‘151592495006172’,
‘apiKey’ => ‘YourAppId’,
‘secret’ => ‘YourAppSecret’,
‘cookie’ => true,
‘locale’ => ‘en_US’,
)
);

Step – 7 : put the loader code in your config/bootstrap.php file,

//app/Config/bootstrap.php
CakePlugin::load(‘Facebook’);

Step – 7 : Use the facebook helper in your class in which you want the facebook login button,

public $Helper = array(‘Facebook’);

Step – 8 : Then use this helper element to your ctp page file where you want to display your active facebook login button,

// echo $this->Facebook->login(array(‘width’ => ‘174’,’height’=>’25’,’scope’ => ’email’, ‘onclick’=>’document.location.href=document.location.href’),__(‘Login with Facebook’,true));

Step – 9 : You can use many facebook functionality like facebook Signup, Like , Share, etc by this facebook plugin code

fb-3

Step – 10 : When you login with the facebook button you have echo on the page the one tab open with the facebook login page please enter your facebook lognin details and you now login with the facebook on your site.