Facebook注销按钮,注销后重定向 [英] Facebook logout button and redirect after logout

查看:174
本文介绍了Facebook注销按钮,注销后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码

<fb:login-button autologoutlink="true" perms="user_likes" size="large"></fb:login-button>

创建一个登录/注销fb按钮. 一切正常,登录后,登录按钮变为注销按钮.但是,如果用户单击注销按钮,则不会刷新当前页面,因此,只有在通过用户身份验证后才应显示的所有内容仍然存在,直到完成手动页面刷新为止.

to create a login/logout fb button. Everything works, after the login, the login button become a logout button. But If the user click on the logout button, the current page is not refreshed and so all the things that should appear only when the user is authenticated are still there until a manual page refresh is done.

如果我获得注销网址(Javascript SDK),则不会发生

This doesn't happen if I get the logout url (Javascript SDK)

$logoutUrl = $facebook->getLogoutUrl();

,然后自己实现注销按钮;在这种情况下,将传递正确的下一个"参数(带有当前页面的网址),然后重新加载当前页面.

and then implement a logout button myself; in that case a proper "next" parameter (with the url of the current page) is passed and the current page is reloaded.

我仍然想使用第一种解决方案,是否可以使用"next"参数?

I still would like to use the first solution, is it possible to make it use the "next" parameter?

推荐答案

自行进行重定向-将其添加到JavaScript中FB.init()之后的某个位置:

Do the redirect yourself - add this to JavaScript, somewhere after FB.init():

<script>
  FB.Event.subscribe("auth.logout", function() {window.location = '/logout'});
</script>

通过FB按钮注销时将触发此功能.

This function will fire when logout through the FB button happens.

这篇关于Facebook注销按钮,注销后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆