facebook登录我的网站

时间:2011-12-22 23:24:16

标签: facebook

我创建了一个网站,现在希望允许用户使用Facebook以及我的登录系统登录。 我添加了下面的代码,它使用facebook按钮登录,然后提示我输入用户名和密码,然后当我点击登录时,它会消失,我的浏览器不会重定向到任何地方。我哪里错了?

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : 'xxxxxxxxxxxxxxx',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>
<fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button>

2 个答案:

答案 0 :(得分:1)

fb:login-button标签可能不是您想要的。我会创建您自己的按钮,然后使用facebook javascript登录方法登录您的用户。

<button type="button" onclick="doLogin()">Log in Here PPL!</button>

然后在脚本标签

var doLogin = function() {
    FB.login(function(response) {
       if (response.authResponse) {
         //they're logged in!  we've got them!
         location='/product/sell_it_now';
       } else {
         console.log('User cancelled login or did not fully authorize.');
       }
     }, {scope: 'email'});
}

从这里开始:https://developers.facebook.com/docs/reference/javascript/FB.login/

答案 1 :(得分:0)

可能是你在localhost机器上尝试这个。

有关更多信息,请按照Facebook文档进行跟进,以清除登录过程:

https://developers.facebook.com/docs/facebook-login/login-flow-for-web