This question already has an answer here:
- Why is Facebook PHP SDK getUser always returning 0? 26 answers
fb.php:
ini_set('display_errors','On');
error_reporting(E_ALL);
require_once 'facebook/src/facebook.php';
$facebook = new Facebook( array (
'appId' => '****',
'secret' => '****',
'cookie' => true
)
);
$user = $facebook->getUser();
if ($user) {
var_dump($user);
$logoutUrl = $facebook->getLogoutUrl();
print '<a href="'.$logoutUrl.'">Logout</a>';
}
else {
$loginUrl = $facebook->getLoginUrl();
print '<a href="'.$loginUrl.'">Login</a>';
}
This is my simple code;
When the link is clicked, and accept the permission box, then I'm redirected to the script, and get this params: http://mydomain.com/fb.php?state=82e166c6a85fd3b44ad655851f885b73&code=AQCMo6L5z-K5juFl3cojl80KllKQ8JE2iKMaOFSmHhHgAFd_V-BfD8YZwbiKQasNuHSbcc4St-9B2gggwEMygn223u8BVK9zXKctEui-y20rcmydx-uf65sw5v6o4XN3k9Lnvtg0jg7h1C9XGC3S1sW32X65CI6kjbe7GXHICpMsT833wDxG1voS7enq9uYm1MGrp83ceTmKvoKGyn_iYby0#_=_
After these issues, I found this link suddenly, getUser became to return 0.(PHP 3.1.1 SDK), but doesn't works for me.
I'm using the PHP Facebook SDK Version 3.1.1.
¿Somebody know whats happening here?