我正在使用codeigniter,并使用javascript sdk / php sdk。但是,从 getLogoutUrl() 生成的注销 url,也会注销我在 facebook.com 的帐户。
有任何功能可以仅为我的网站应用程序清除会话..?
您只能撤销您的应用程序的权限。 看看这个页面:
http://developers.facebook.com/docs/howtos/login/server-side-logout/
以下是完成此操作的 PHP 代码:
$token = $_SESSION["access_token"];
if($token)
{
$graph_url = "https://graph.facebook.com/me/permissions?method=delete&access_token=".$token;
$result = json_decode(file_get_contents($graph_url));
}
else
{
echo("User already logged out.");
}
将以下内容添加到您网站页面的最开头
session_start();
if($_GET['logoutfrmfb']=="logout")
{
unset($_SESSION['fb_{your app id}_code']);
unset($_SESSION['fb_{your app id}_access_token']);
unset($_SESSION['fb_{your app id}_user_id']);
}
在 src/base_facebook.php 中找到并编辑以下行(可能是第 506-515 行)
public function getLogoutUrl($params=array()) {
return $this->getUrl(
'www',
'logout.php',
array_merge(array(
'next' => $this->getCurrentUrl().'?logoutfrmfb=logout',
'access_token' => $this->getAccessToken(),
), $params)
);
}
对我有用!
是的..我有同样的问题..您只需执行以下操作即可做到这一点:
在您的页面中退出按钮或图像:
<a href="logout.php">Log Out</a>
logout.php ------------------------------------------------------>
<?php
require 'facebook.php'; //including the facebook php sdk
$facebook->destroySession();
header( "location:index.php" );
?>
使用时
facebook=>getLogoutUrl();
<<<<< this makes your facebook.com logout ...
我希望这就是您正在寻找的:)