我只是想设置 Facebook Connect 以允许在我已经建立的网站上选择使用注册表单注册,或者使用 Facebook Connect 注册(这真的应该比现在更容易,过时的文档让我发疯).当用户单击该按钮时,它会打开弹出窗口并要求允许我正确要求的内容。但是,当他们单击“允许”时,它会再次要求允许(但只是基本的个人资料信息)。这显然是由单击 fb:login-button 的默认操作触发的,即使他们已经登录并允许该应用访问他们的数据。
<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>
最佳答案
显然,您可以只在 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>
关于facebook - 使用 XFBML 登录按钮要求用户进行两次身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2977193/