Reputation: 135
in template:
<div><fb:registration redirect_uri=http://mydomain/users/register fields="name,birthday,gender,location,email" /></div>
In model and Controller, I have function register() in users model and controller
define('FACEBOOK_APP_ID', ''); // Place your App Id here
define('FACEBOOK_SECRET', ''); // Place your App Secret Here
// No need to change the function body
function parse_signed_request($signed_request, $secret)
{
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256')
{
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig)
{
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input)
{
return base64_decode(strtr($input, '-_', '+/'));
}
if ($_REQUEST)
{
$response = parse_signed_request($_REQUEST['signed_request'],
FACEBOOK_SECRET);
$name = $response["registration"]["name"];
$email = $response["registration"]["email"];
$password = $response["registration"]["password"];
$country = $response["user"]["country"];
echo $country;
echo $name;
echo $email;
echo $password;
...............
So its working fine and I am getting data from facebook. I want to integrate this code with my cakephp registration code. I am very new to cakephp, so please if any body give me a link, how to integrate facebook registration plugin in cakephp?
Upvotes: 0
Views: 768
Reputation: 3562
Please try this.
http://www.webtechnick.com/blogs/view/229/CakePHP_Facebook_Plugin_Auth_Facebook_and_more
It has many more features to implement various Facebook functionality like login, registration, share, comments etc.
I've used this for login functionality and its working fine.
Upvotes: 1