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

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

问题描述:

这是Facebook登录按钮上的信息

This is the info on Facebook Login button

http://developers.facebook.com/docs/guides/web/

所以它会渲染一个登录按钮,一个用户可以点击它在Facebook上登录(将弹出登录窗口)
但是用户登录后,即使赞或共享按钮现在工作,但是登录按钮仍然显示。

So it will render a Login button, and a user can click on it to log in on Facebook (a log in window will pop up) But after the user logs in, even though the Like or Share buttons work now, but the Log in button still shows.

1)在用户成功登录后有没有办法重定向到URL?

2)另一种方法是动态更改登录按钮到看不见或更好,
显示为以[彼得(用户名)]登录

1) Is there a way to redirect to a URL after the user successfully logs in?
2) Another way is to dynamically change the Log in button to invisible or better yet, show it as "Logged in as [Peter (username)]"

如何(1)和/或(2)做了什么? (我在Facebook应用设置中看不到回调网址,并且重定向可能需要从网站A或网页B上的不同网址)。

How can (1) and/or (2) be done? (I don't see a callback URL in the Facebook app setting and also the redirection may need to go to different URL from page A or page B on the website)

更新:我发现有关< fb:login-button on-login =top.location ='...';> 但是我看到一些网站做重定向,但是没有 on-login ='...'

Update: I found some info about <fb:login-button on-login="top.location = '...'; "> but I see some website doing the redirect but there is no on-login='...'

1)您也可以使用这样的代码重新登录(请注意 auth.login event):

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/