1
votes

I have been trying for hours now to log a user out of Facebook.com using the official php sdk V2.4 (https://github.com/facebook/facebook-php-sdk-v4/) and api endpoint version V2.5.

What I found until now is that I should use

$facebook->destroySession();

However this function is not available if I use

$facebook = new Facebook\Facebook([
  'app_id' => $app_id,
  'app_secret' => $app_secret,
  'default_graph_version' => 'v2.5',
]);

So instead I used

$helper = $facebook ->getRedirectLoginHelper();
$logoutUrl = $helper->getLogoutUrl($user['facebookAccessToken'], 'www.mypage.com');

This returns

$logoutUrl = https://www.facebook.com/logout.php?next=www.mypage.com&access_token=facebookToken

I checked the token and it is correct. However when I redirect to $logoutUrl then facebook does not logout the user but instead redirects to https://www.facebook.com/home.php while the user is still logged in.

I guess that this is due to the new version V2.5? Is there any way to accomplish this task with the new version?

Thanks a lot in advance!

1
The redirect url www.mypage.com must be a registered domain with this app; - Mukesh Yadav

1 Answers

0
votes

Ok nevermind, I found out why it didn't work. The problem was that I used xampp on my localhost to debug it. But the redirect link was set to the homepage. After I changed the redirect link to the localhost address it was working.

Hope this helps, if anyone else ever struggles with this.

Cheers