如何正确捕获访问令牌?

发布于 2024-12-25 14:25:24 字数 721 浏览 3 评论 0原文

即使我退出 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮酒 2025-01-01 14:25:24

访问令牌不取决于您在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文