当用户按下注销按钮时,它不会清除会话或cookie。这意味着在我刷新它之后,它仍然会登录。在我添加了破坏会话后,它可以工作,但它也会在我的网站www.facebook.com上和我的网站一起登出我的脸书。
<?php
function facebooklogin(){
include ('libs/facebook.php');
$facebook = new Facebook(array(
'appId' => '[my app id]',
'secret' => '[my secret]',
'cookie' => true
));
$session = $facebook->getUser();
$me = null;
if ($session)
{
try
{
$me = $facebook ->api('/me');
$facebook->api ('/me');
$_SESSION['id'] = $me['id'];
$_SESSION['email'] = $me['email'];
$_SESSION['name'] = $me['name'];
//print_r($me);
printf($me['id']);
printf($me['email']);
printf($me['name']);
}
catch (FacebookApiException $e)
{
echo $e->getMessage();
}
}
if ($me)
{
$logoutUrl = $facebook->getLogoutUrl();
echo "<a href='$logoutUrl'><img src=assests/images/fblogoutbtn.png></a>";
}
else
{
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'publish_stream, read_friendlists,email')
);
echo "<a href='$loginUrl'><img src=assests/images/fbbtn.png></a>";
}
}