facebook php-sdk 未注销

发布于 2024-12-23 00:43:34 字数 576 浏览 1 评论 0原文

我很难让它发挥作用。我使用以下内容生成注销 url:

$logout = "https://www.facebook.com/logout.php?next=" . urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']) . "&access_token=" . $facebook->getAccessToken();

生成正确的(与上一个版本一起使用)url:

https://www.facebook.com/logout.php?next=http%3A%2F%2F...&access_token=AA....ZD

但是,这实际上并没有使用户注销。我尝试使用

$facebook->getLogoutUrl(array('next' => 'myurl')) 

它生成几乎相同的网址。这也行不通。我不明白为什么它不注销用户。实际上,我尝试手动将地址放入地址栏中,但它会将我重定向到 Facebook 主页。

I'm having a hard time getting this to work. I use the following to generate the logout url:

$logout = "https://www.facebook.com/logout.php?next=" . urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']) . "&access_token=" . $facebook->getAccessToken();

Which generates the correct (worked with the last version) url:

https://www.facebook.com/logout.php?next=http%3A%2F%2F...&access_token=AA....ZD

However this does not actually log the user out. I tried using

$facebook->getLogoutUrl(array('next' => 'myurl')) 

which generates pretty much the same url. This also did not work. I am lost as to why its not logging the user out. I actually tried manually putting the address into the address bar but it redirects me to the Facebook homepage.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

记忆で 2024-12-30 00:43:34

facebook php sdk 使用 php 会话来保持登录状态。要清除它,您只需销毁会话即可。

index.php:

<a href="logout.php">Log out</a>

logout.php

$facebook = new Facebook(array('appId'  => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
$facebook->destroySession();
header('location: index.php');

FB_APP_ID 和 FB_SECRET 是我的特定应用程序信息。换成你自己的。

The facebook php sdk uses php sessions to tokens that keep you logged in. To clear it, you can just destroy the session.

index.php:

<a href="logout.php">Log out</a>

logout.php

$facebook = new Facebook(array('appId'  => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
$facebook->destroySession();
header('location: index.php');

FB_APP_ID and FB_SECRET are my specific apps info. Replace with your own.

浅忆流年 2024-12-30 00:43:34

如果您在使用 Facebook PHP SDK 时请求 offline_access 权限(有时甚至没有它),则会导致默认注销功能无法正常工作。为了解决这个问题,以下内容对我有用:

//change your logout url to 
$logoutUrl = $facebook->getLogoutUrl(array( 'next' => ($fbconfig['baseurl'].'logout.php') ));

//on logout page
setcookie('fbs_'.$facebook->getAppId(), '', time()-100, '/', 'domain.com');
session_destroy();
header('Location: /');

If you request the offline_access permission when using the Facebook PHP SDK (and sometimes even without it), it makes the default logout functionality not work very well. To fix this, following worked for me:

//change your logout url to 
$logoutUrl = $facebook->getLogoutUrl(array( 'next' => ($fbconfig['baseurl'].'logout.php') ));

//on logout page
setcookie('fbs_'.$facebook->getAppId(), '', time()-100, '/', 'domain.com');
session_destroy();
header('Location: /');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文