'getLogoutUrl' Does not work

2019-07-28 23:31发布

After I click on my logout button, it redirects me to: https://www.facebook.com/home.php. Why is it that when I return to my app domain, I can still see the logout button...?

Here is my code:

<?php
//User login/logout buttons
if($user) {
    echo '<a href="'.$facebook->getLogoutUrl(array('next' => 'myurl.com/facebook/')).'"><img src="src/logout-fb.png" alt="Facebook Logout Button" /></a>';
}else{
    $params = array(
        scope => 'user_photos, publish_stream',
        redirect_uri => 'http://myurl.com/facebook/'
    );
    $loginUrl = $facebook->getLoginUrl($params);
    echo '<a href="'.$loginUrl.'"><img src="src/login-fb.gif" alt="Facebook Logout Button" /></a>';
}
?>

Thanks in advance.

5条回答
乱世女痞
2楼-- · 2019-07-28 23:48

as I guess the URL's should be absolute as below hope this solve your problems... ;-)

$logoutParams = array(
'next'  =>  'http://localhost/Facebook/test/test1/after_logout.php'
);
查看更多
对你真心纯属浪费
3楼-- · 2019-07-28 23:51

I was facing the same problem in one of my Facebook App. I was putting redirect URL correctly, everything seems fine. But then I realize that my domain is missing in Facebook App settings.

For you Facebook App set your domain e-g "example.com"

Last and important that your Redirect URL in the Facebook's Log out URL should be within your domain you have specified in Facebook App settings.

查看更多
爷的心禁止访问
4楼-- · 2019-07-28 23:55

I just added my application's canvas URL in "next" parameter and it works.

查看更多
够拽才男人
5楼-- · 2019-07-28 23:57

Had similar problem. The URL you're redirecting too needs to be within the your Site Domain as defined within the Developer App. I was testing with google.com for an example and it wasn't logging out.

查看更多
神经病院院长
6楼-- · 2019-07-28 23:58

I had the same problem:

When clicking on my logout link, Facebook ignored the "next" parameter, did not logout and redirect to facebook.com/home.php.

I added a final slash to my "next" URL and it solved my problem.

There is my code:

$client = facebook_client();
if($client){
  session_destroy();
  $url = $client->getLogoutUrl(array('next' => $base_url.'/')); //added a slash
  ... //Redirect to $url
}
查看更多
登录 后发表回答