所以更新到PHP 3.0 sdk后什么不是,我的 FB.login() 函数不再要求我设置它要求的权限。还有其他人得到这个吗?这里有一些代码给你:
window.fbAsyncInit = function() {
FB.init({
appId: 'xxx',
status: true,
cookie: true,
xfbml: true,
oauth : true // enables OAuth 2.0
});
// whenever the user logs in, we refresh the page
//FB.Event.subscribe('auth.login', function() {
// window.location.reload();
//});
};
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
FB.logout(function(response) {
console.log('Logged out.');
});
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope:'read_stream,publish_stream,offline_access'});
我试图访问它的方式是通过 onClick="FB.login();"。有人可以帮忙吗?
检查JS SDK的来源我发现他们仍然使用 烫发 并不是 范围 因为它记录在案。
这对我有用:
...的onclick =“的FB.login(handleLoginResponse,
{perms:'email,manage_pages,user_birthday'});返回false;“...
我希望它有所帮助。
我用JS SDK看到了与此相关的内容。设置时 oauth=true, 功能
FB.login(function (response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, { scope: 'email,publish_stream,user_birthday,user_location' });
正确请求扩展权限,但使用 <fb:login-button> FBXML 同 scope="email,publish_stream,user_birthday,user_location" 才不是。
对我来说这看起来像Facebook的bug ...
我的问题与你相似。
我已经检查了所有的javascript,以验证我的范围在FB.login定义中是否良好。
最后我意识到我的HTML中有一个Facebook按钮。
<form class="form-signin"><fb:login-button size="large">Facebook</fb:login-button></form>
当我还在FB按钮中定义范围时,如果我更改范围,Facebook会要求我正确接受新权限
<form class="form-signin"><fb:login-button size="large" scope="<?php print($sFacebookScope);?>">Facebook</fb:login-button></form>
我认为是因为你在打电话 FB.logout 在...内 FB.login 块。
实际上发生的事情是,一旦他们登录,他们就会被注销。
所以分开这样:
// CALLED WHEN USER LOGS IN
function userLogin() {
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope:'read_stream,publish_stream,offline_access'});
}
// CALLED WHEN USER LOGS OUT
function userLogout() {
FB.logout(function(response) {
console.log('Logged out.');
});
}
我有完全相同的问题,直到我意识到这是一个浏览器/ Facebook缓存问题。确保您在网站空间中拥有最新代码,并在新浏览器中测试您的应用程序(如果可能是您的问题的解决方案)。
对我有用的唯一解决方案是将权限放在登录按钮标记中,如下所示:
<fb:login-button show-faces =“true”width =“200”max-rows =“1”data-scope =“email”></ fb:login-button>