Facebook Logout [closed]
Hello i am trying to logout using file_get_contents.
Here is my code
<?php echo file_get_contents("http://www.facebook.com/logout.php"); ?>
i am not able to logout From Facebook .
Can AnyBody Help
Thanks
Logging out involves a lot more than doing a simple HTTP request. For one, you need the session id of the user you're trying to log off. When you execute this code, your server is actually the one doing the request, not the user using your system (and logged onto Facebook). So Facebook has no idea who you're trying to logout.
If you really want to do this, you should set up a Curl session, and pass the session id. But easier is, to provide a link to the user. If they go to the URL, their session id is passed automatically.
Add the following to the very beginning of your website page
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']);
}
Find and edit the following lines in src/base_facebook.php (probably lines 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)
);
}
works for me!
精彩评论