facebook getLogoutUrl returns a URL with access_token=0, when clicked redirects to Facebook user's home page

facebook, facebook-graph-api, facebook-php-sdk, php

Solution

Okay, I've solved this by creating my own logout URL and adding an access token

$logoutUrl = 'https://www.facebook.com/logout.php?next=http://mydomain.com/logout.php&access_token=' . $facebook->getAccessToken();

Problem

I'm integrating Facebook with my site and I've added a Logout button whose URL is taken from: ``` $facebook->getLogoutUrl(array('next' => 'http://mydomain.com/logout.php')); ``` The problem is that `logout.php` is never called. Instead, on click of the Logout button, it redirects to the logged-in user's Facebook home page. It doesn't log the user out of Facebook, and it doesn't call my `next` URL. I noticed that the URL generated by `getLogoutURL()` looks like: ``` https://www.facebook.com/logout.php?next=http://mydomain.com/logout.php&access_token=0 ``` Notice there is an access_token=0. Should that value not be zero? That's the only thing I can think of that might be causing the problem. I've already set my FB app's Site URL to `http://mydomain.com`. While testing locally, I've also edited my `hosts` file. I've also googled a lot and I haven't found a solution. The only one that worked was adding an `onclick` to my logout button using `FB.logout()`. But I would need to use PHP. Any ideas as to why the logout URL is not working?

Original source