im getting "OAuthException: An active access token must be used to query information about the current user" once every two page loads (with any authenticated user), the correct load gets the user info with out any problems.
This is my current script:
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXX',
'cookie' => true,
));
//obtiene las Variables Iniciales
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array( 'next' => ('http://xxxxx.com/Salir') ));
} else {
$loginUrl = $facebook->getLoginUrl(array('scope' => 'email,user_birthday,user_hometown,user_location'));
}
This is the button:
<fb:login-button perms='email,user_birthday,user_hometown,user_location' length='long' autologoutlink='false' onlogin='fbLogin();'></fb:login-button>
<div id='fb-root'></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '$FBid',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
return false;
});
FB.Event.subscribe('auth.logout', function(response) {
return false;
});
};
(function() {var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/es_ES/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
Does anyone have any idea about why this is happening?
Thanks for the help :D
I apologize for my bad English.