I have a php script using Facebooks sdk which logins using the following code:
$user = $facebook->getUser();
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array( 'next' => ($user['baseurl'].'logout.php') ));
} else {
$loginUrl = $facebook->getLoginUrl(array('scope'=>'offline_access, manage_pages, publish_stream'));
}
if ($user) {
echo '<div class="login"><a href="'.$logoutUrl.'">Logout</a></div>';
}
else {
echo '<div class="login">
Login using OAuth 2.0 handled by the PHP SDK:
<a href="'.$loginUrl.'">Login with Facebook</a>
</div>';
}
The script refreshes and posts to my facebook wall once an hour for a total of nine hours. The problem is that randomly getUser() will fail and I will be forced to manually login again. I'm not sure what's causing the getUser() failure or how to fix it?