简体   繁体   English

PHP Facebook注销

[英]PHP Facebook logout

I am using PHP SDK for creating facebook login, which works fine but when I want to logout and I use getLogoutUrl method which returns logout url in this form: 我正在使用PHP SDK创建Facebook登录,效果很好,但是当我要注销时,我使用getLogoutUrl方法以这种形式返回注销网址:

https://www.facebook.com/logout?next=google.com&access_token=my_access_token

After I redirect to this page I get to the This page is not avalible page on FB and I am not logged out. 重定向到此页面后,进入FB上的“ 此页面不可用”页面,并且我没有注销。 Any idea what could be wrong ? 知道有什么问题吗? or it will be SDK bug ? 否则将是SDK错误? thanks. 谢谢。

I have created a article for facebook login logout with graph api with php. 我创建了一篇文章,介绍了使用php图形api进行Facebook登录登出。 You can see the following code for logout from facebook with php. 您可以使用php查看以下代码以从Facebook注销。 This is code for logout.php 这是logout.php的代码

session_start();
if(isset($_SESSION['fb_access_token'])){
    require_once 'php-graph-sdk-5.5/src/Facebook/autoload.php';
    $fb = new Facebook\Facebook([
      'app_id' => 'app-id', // Replace {app-id} with your app id
      'app_secret' => 'app-id-secret',
      'default_graph_version' => 'v2.4',
    ]);
    $url = 'https://www.facebook.com/logout.php?next=your-website-return-url/&access_token='.$_SESSION['fb_access_token'];
    session_destroy();
    header('Location: '.$url);
}

If you need full source code then you can see this link 如果您需要完整的源代码,则可以看到此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM