function validateFacebookUser() {
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'id here',
'secret' => 'secret here',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
echo("<script> top.location.href='" . $loginUrl . "'</script>");
}
}
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'id here',
'secret' => 'secret here',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
echo("<script> top.location.href='" . $loginUrl . "'</script>");
}
}
0 comments:
Post a Comment