这是我的第一篇SO帖子,请原谅任何不合适的手势。
我正在使用Facebook PHP SDK,但无法正确注销。我认为这是浏览器缓存变量的一些问题,在任何情况下,都会感谢有关如何纠正此问题的帮助。
我的代码是
$fb = new Facebook('appId' => $appId, 'secret' => $appSecret, 'cache' => true);
$scope = array();
$user = $fb->getUser();
if ($user) { //user may be logged out even if this is non-zero
try {
$profile = $fb->api('/me', 'GET'); // this should definitely give an exception if
// user is logged out
echo $fb->getLogoutUrl(); // since the previous state didnt generate an exception,
// we can be sure that user is correctly logged in, so
// an option to logout
} catch(FacebookApiException $e) {
echo $fb->getLoginUrl(); // since an exception was thrown, user was NOT logged in
}
} else {
echo $fb->getLoginUrl(); // as $user is 0, this means user is clearly not logged in
}
现在,由于我从index.php重定向到facebook.com/logout.php然后再返回到index.php,上述逻辑应该在用户登录和注销时都能正常工作。 但即使点击退出网址,“$ fb-> api('/ me','GET')”调用也不会抛出异常。有什么建议吗?