如何正确捕获访问令牌?
即使我退出 Facebook,我似乎也无法发现访问令牌无效。
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
echo "Name: " . $user_profile['name'];
} catch (FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
error_log($e);
$user = null;
}
}
即使我注销 Facebook,我仍然可以取回用户名。所以显然访问令牌似乎仍然有效。我该如何解决这个问题?
或者我应该只在 iframe 的 FB 环境中测试我的应用程序?
I can't seem to catch the access token as invalid even when i logged out of facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
echo "Name: " . $user_profile['name'];
} catch (FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
error_log($e);
$user = null;
}
}
I am still getting the user name back even when i am logout of facebook. So apparently the access token seems still valid. How can i fix this?
Or should i test my app only in FB enviroment in an iframe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
访问令牌不取决于您在 Facebook 上的身份验证状态。您正在使用的 Facebook PHP SDK 将访问令牌存储在 PHP 会话中。所以,你可以清理你的会话。
The access token does not depend on yours auth status on Facebook. Facebook PHP SDK, that you are using, stores access token in PHP session. So, you can just clean your session.