如果在 FB 开发者网站的某个地方清楚地记录了这一点,我提前道歉 - 但我找不到它(所以请在适当的情况下链接我)。
我使用 GAE + Python 在网站上实现了 FB 登录按钮。这是 HTML:
<fb:login-button></fb:login-button>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: 'ad16a806fc10bef5d30881322e73be68', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
// A user has logged in, and a new cookie has been saved
} else {
// The user has logged out, and the cookie has been cleared
}
});
</script>
目前的行为是 - 如果我点击“登录”按钮,系统会要求我允许应用程序访问 FB。然后我选择“确定”。但是登录按钮仍然显示“登录”而不是“注销”。我该如何实现?在服务器端还是客户端?
最佳答案
它没有记录在 FB SDK 中 login-button page出于某种原因,但您可以将 autologoutlink="true"
属性添加到标记中,如果您已登录,它将显示一个注销按钮,而不是仅仅使该按钮不可见。
<fb:login-button autologoutlink="true"></fb:login-button>
警告:如果您在登录按钮上使用自定义文本(如
),它将忽略该标签<!-- This will always display the button, whether you are logged in or out -->
<fb:login-button autologoutlink="true">Login To My Service!</fb:login-button>
关于javascript - 如何让 Facebook 登录按钮显示 "Logout",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4522427/