如何让Facebook登录按钮重定向到特定的URL [英] How to let Facebook Login button redirect to a particular URL

查看:82
本文介绍了如何让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/

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

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