When I run this code and my cookies have been cleared and I am not registered on facebook. He directs me to facebook and I log in, but when he brings me back to my page, it is the same where, as the profile picture should be shown, etc ....
I, apparently, narrowed down the problem of the return statement from $ user because it returns 0. I looked at this code for a long time and I did not find what I was doing wrong.
What I need to change in order to get it so that when I get back from facebook login, it will show pic profile and so on ...
<?php
require_once 'libs/facebook.php';
require 'connections/connection.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxx',
));
$user = $facebook->getUser();
echo $user;
if ($user) {
try {
$user_profile = $facebook->api('/me');
echo $user;
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array('next' => ($fbconfig['baseurl'] . 'logout.php')));
} else {
$statusUrl = $facebook->getLoginStatusUrl();
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'user_about_me',
'scope' => 'read_friendlists'
));
}
?>
source
share