Facebook(FB.login)没有请求我的权限

Joh*_*hny 11 permissions scope facebook facebook-php-sdk

所以在更新到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'});
Run Code Online (Sandbox Code Playgroud)

我试图访问它的方式是通过onClick="FB.login();".有人可以帮忙吗?

小智 5

检查JS SDK的源代码我发现它们仍然使用perms而不是它记录的范围.这对我有用:

... onclick ="FB.login(handleLoginResponse,{perms:'email,manage_pages,user_birthday'}); return false;"...

我希望它有所帮助.

  • 只是提醒一下,这些信息已经过时了.试试这个,你会得到"未捕获错误:的OAuth2规范规定,'烫发’,现在应该叫'范围’请更新." (4认同)