我有以下脚本,它允许用户使用他们的 facebook 帐户登录我的网站,请求适当的权限,如果被接受,它将在墙上发布一条消息:
<?php
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'removed for security reasons',
'secret' => 'removed for security reasons',
'cookie' => true,
));
$session = $facebook->getSession();
if ($session) {
if (isset($_GET[id])) {
$post = $facebook->api("/" . $_GET['id'] . "/feed", "POST", array('message' => 'Hello!'));
echo 'A message has been posted on your friends wall';
} else {
$friends = $facebook->api('/me/friends');
foreach ($friends as $key=>$value) {
echo 'You have ' . count($value) . ' friends<br />';
foreach ($value as $fkey=>$fvalue) {
echo 'friend id = ' . $fvalue[id] . ' - friend name = ' . $fvalue[name] . ' - <a href="/stage0.php?id=' . $fvalue[id] . '">post message</a><br />';
}
}
}
} else {
$loginUrl = $facebook->getLoginUrl(array(
'req_perms' => 'publish_stream',
'next' => 'http://'.$_SERVER['SERVER_NAME'].'/stage0.php',
'cancel_url' => 'http://'.$_SERVER['SERVER_NAME'].'/cancel.php',
));
header('Location: '.$loginUrl);
}
?>
然后我有以下脚本来注销用户:
<?php
error_reporting( E_ALL | E_STRICT );
ini_set('display_errors', 1);
?>
<?php
session_start();
?>
<html>
<head>
<title></title>
<?php
$_SESSION = array();
session_destroy();
?>
<meta http-equiv="refresh" content="0;index.php">
</head>
<body>
<h1>logout</h1>
</body>
</html>
这会清除我创建的会话,但根本不会将它们从 facebook 中注销。如何清除我创建的会话并将它们从 facebook 中注销?