I used that code to connect to facebook
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
ob_clean();
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
then logOut form facebook
if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
<?php endif;
if the user clicks the link, then logOut. but I want just running pace code. not link. in the page, ı will work where ı wrote.
I did like that but didn't work
header('Location: '.$logoutUrl );
To sum up: in my page I want to LOGOUT not only in my cookies but also on facebook.
like that:
if(!isset($_COOKIE["kullanici"]))
{
echo "Giriþ yapmamýþsýnýz Bu sayfaya giriþ izniniz yoktur...";
exit();
}
else
{
setcookie("kullanici_mail", "", time()-3600,"/");
if($user)
// here FACBOOK LOGOUT CODE SHOULD BE
// AND THAN GO
?>
<script language="JavaScript">
<!-- Sakla
parent.location.href="../index.php";
// -->
</script>
<?
}