<script>
FB.init({appId: <?php echo FACEBOOK_APP_ID;?>, status: true, cookie: true, xfbml: true});
FB.Event.subscribe('auth.logout', function(response) {});
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
FB.api('/me', function(response) {
if(response.id!='undefined')
{
window.location='Fbaccess.php?first_name='+response.first_name+'&last_name='+response.last_name+'&email='+response.email;
}
else
{
window.location='login.php';
}
});
} else {
// The user has logged out, and the cookie has been cleared
}
});
</script>
php code ....
<?php
$cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
if(isset($cookie))
{
$first_name = json_decode(@file_get_contents('https://graph.facebook.com/me?access_token=' .$cookie['access_token']))->first_name;
$last_name = json_decode(@file_get_contents('https://graph.facebook.com/me?access_token=' .$cookie['access_token']))->last_name;
}
?>
function get_facebook_cookie($app_id, $application_secret)
{
$args = array();
parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
ksort($args);
$payload = '';
foreach ($args as $key => $value)
{
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $application_secret) != $args['sig']) {
return null;
}
return $args;
}
i think this much code is available for you to get facebook name and user id ....
on this url you will find whole response
https://graph.facebook.com/me?access_token=' .$cookie['access_token']