user a – Admin for the app
Running the app on HTTP
getUser() is giving the user id
user b – not the admin
Running the app on HTTP
getUser() is giving zero and the URL is like this &error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&state=32423dfs23423dsaaw#=
Below is the code user for auth the user,
$facebook = new Facebook(array(
'appId' => '',
'secret' => '',
'cookie' => true
));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'publish_stream,email',
'redirect_uri' => 'https://www.facebook.com/pages/test?sk=app_23423423'
)
);
if (!$user) {?>
<a href="<?php echo $loginUrl ?>">Facebook Login</a>
else
{
echo "<script type='text/javascript'>location.href = 'test.php?Id=$user'</script>";
}
}
Whenever you get
in the $_REQUEST back from the Facebook then you will no get User ID and this is because the user has logged in or authorized your app so that you might retrieve the User ID. This is same as the case when no user has logged in. You can get reason and description from the $_REQUEST[‘error_reason’] and $_REQUEST[‘error_description’] respectively to display further details to user or for your records.