PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 4, 2022

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

 February 04, 2022     facebook, facebook-graph-api, facebook-php-sdk, php     No comments   

Issue

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?


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();


Answered By - Obay
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing