6

我只是想设置 Facebook Connect 以允许在我已经建立的网站上选择使用注册表单进行注册,或者使用 Facebook Connect 进行注册(这真的应该比现在更容易,过时的文档让我发疯了)。当用户单击按钮时,它会打开弹出窗口并要求允许我正确询问的内容。但是,当他们单击允许时,它会再次要求允许(但只是基本的个人资料信息)。这显然是由单击 fb:login 按钮的默认操作触发的,即使他们已经登录并允许应用程序访问他们的数据。

<fb:login-button size="medium" length="long" v="2" onclick="fb_login()"></fb:login-button>
<div id="fb-root"></div>
<script src="http://static.ak.fbcdn.net/connect/en_US/core.js"></script>
<script>
    FB.init({appId: '<app_id>', status: true, cookie: true, xfbml: true});

    function fb_login() {
        FB.login(function(response) {
            if (response.session) {
                if (response.perms) {
                    // they have allowed the app, continue with registration
                }
            }
        }, {perms:'email,user_birthday'});
    }
</script>
4

2 回答 2

8

显然,您可以只在 FBML 中分配权限,并且可以完全绕过调用 FB.login。如果 Facebook 在他们的文档(咆哮)中提到这一点,那就太好了。

<fb:login-button size="medium" length="long" v="2" perms="email,user_birthday" onlogin="fb_login()"></fb:login-button>
<div id="fb-root"></div>
<script src="http://static.ak.fbcdn.net/connect/en_US/core.js"></script>
<script>
    FB.init({appId: '<app_id>', status: true, cookie: true, xfbml: true});

    function fb_login() {
           // they have allowed the app, continue with registration
    }
</script>
于 2010-06-05T02:04:10.520 回答
0

我很确定问题在于将“onclick”事件分配给fb:login-button已经有自己的默认行为的事件。只需放弃该登录按钮标记并使用该 onclick 事件创建您自己的常规 html 按钮(链接、图像或任何您想要的)。

于 2010-06-04T21:13:30.993 回答