且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何让 Facebook 登录按钮重定向到特定 URL

更新时间:2022-04-14 03:01:30

1) 您还可以使用如下代码重定向登录(注意 auth.login 事件):

1) You can also redirect on login using some code like this (note the auth.login event):

 <script src="http://connect.facebook.net/en_US/all.js">
  </script>
  <script>
      FB.init({
          appId: '??????????????', cookie: true,
          status: true, xfbml: true
      });
      FB.Event.subscribe('auth.login', function () {
          window.location = "http://example.com";
      });
  </script>
  <fb:login-button>
     Login with Facebook
  </fb:login-button>

2) 要确定是否显示或隐藏登录按钮,您可以使用FB.getLoginStatus 来发现用户是否已登录.以下页面可能有用:http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/一个>

2) To determine whether to show or hide the login button, you can use FB.getLoginStatus to discover whether the user is logged in. The following page might be of use: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/