简体   繁体   中英

How to make user signed out from facebook when he logs out of facebook application on a php website

I have the following code which runs when user clicks on logout button:

if ($_GET['m'] == 'logout'){
session_destroy();
$facebook->destroySession();
header("Location: /");

}

The user is logged out of facebook app but is still online on Facebook. How to sign out the user from facebook too? Thanks

Use php sdk of facebook and paste below code in your file

    require_once 'facebook/src/facebook.php';
    $facebook = new Facebook (array(
         'appId'  => '*****************',
         'secret' => '****************************'  
));

 $user = $facebook->getUser();
$homeurl = 'index.php';//url you want to redirect after facebook logout


if ($user) 
{
      $logoutUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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