Skip to content

Instantly share code, notes, and snippets.

@richardpilgrim
Created October 5, 2013 15:43
Show Gist options
  • Save richardpilgrim/6842442 to your computer and use it in GitHub Desktop.
Save richardpilgrim/6842442 to your computer and use it in GitHub Desktop.
Facebook PHP Logout Example Code to only logout user from app and not from Facebook. Essentially revoke the permission from your app.
<?php
require '../src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '<appid>',
'secret' => '<appsecret>',
));
// Get User ID
$user = $facebook->getUser();
if($user)
{
$permissions = $user.'/permissions';
$facebook->api($permissions, "DELETE");
session_destroy();
header("Location: example.php");
die();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment