FB.ui方法'auth.login'不起作用

时间:2011-07-17 22:15:25

标签: facebook-graph-api

它不会打开任何东西。

function logIN()
{
    FB.ui({
        method: 'auth.login',
        perms: 'email',
        display: 'iframe' },
        function(response) {
            /* */
        });
}

2 个答案:

答案 0 :(得分:1)

我相信这应该是你的功能:

FB.ui({
  method: 'oauth',
  display: 'popup',
  scope: 'email',
  response_type: 'token',
  redirect_uri: 'WHEREYOUWANTTOPROCESSTOKEN',
  client_id: 'YOURAPPID',
});

请注意,只有pagepopupdisplay的有效类型

答案 1 :(得分:1)

此示例可能有所帮助:http://fbrell.com/auth/login-and-logout

<button id="fb-auth">Login</button>

<script>
function updateButton(response) {
  console.log('Updating Button', response);
  var button = document.getElementById('fb-auth');

  if (response.session) {
    button.innerHTML = 'Logout';
    button.onclick = function() {
      FB.logout(function(response) {
        console.log('FB.logout callback', response);
      });
    };
  } else {
    button.innerHTML = 'Login';
    button.onclick = function() {
      FB.login(function(response) {
        console.log('FB.login callback', response);
        if (response.session) {
          console.log('User is logged in');
        } else {
          console.log('User is logged out');
        }
      });
    };
  }
}

// run it once with the current status and also whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
</script>