如何让Facebook登录按钮显示"退出"

Wil*_*ran 6 javascript python facebook facebook-graph-api

如果在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>
Run Code Online (Sandbox Code Playgroud)

目前的行为是 - 如果我点击"登录"按钮,我被要求允许应用程序访问FB.然后我选择"OK".但是登录按钮仍然显示"登录"而不是"注销".我该如何实现?在服务器端还是客户端?

Der*_*mer 24

由于某种原因,它没有记录在FB SDK 登录按钮页面上,但您可以将该autologoutlink="true"属性添加到标记中,如果您已登录它将显示注销按钮,而不仅仅是使按钮不可见.

<fb:login-button autologoutlink="true"></fb:login-button>
Run Code Online (Sandbox Code Playgroud)

警告:如果您在登录按钮上使用自定义文本,它将忽略该标记

<!-- 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>
Run Code Online (Sandbox Code Playgroud)


Wil*_*ran 0

感谢用户“哈哈”,解决方案是:

1) 获取 Facebook Python SDK:https://github.com/facebook/python-sdk/tree/master/examples/appengine 2) 实现 HTML 示例: https: //github.com/facebook/python-sdk/ blob/master/examples/appengine/example.html 3) 更新您的主请求处理程序和模型:https://github.com/facebook/python-sdk/blob/master/examples/appengine/example.py