oauth成功后调用函数

时间:2011-10-27 13:09:40

标签: facebook authentication oauth-2.0

当Facebook被自动化后,如何调用函数?

FB.ui({
    client_id: '9999999999999',
    method: 'oauth',
    scope: 'email, user_about_me, user_likes',
    response_type: 'token'
});

???

2 个答案:

答案 0 :(得分:1)

FB.Ui有callback function

FB.ui(
  {
    method: 'feed',
    name: 'Facebook Dialogs',
    link: 'https://developers.facebook.com/docs/reference/dialogs/',
    picture: 'http://fbrell.com/f8.jpg',
    caption: 'Reference Documentation',
    description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

答案 1 :(得分:0)

Facebook声明您不应直接使用来自Javascript SDK的OAuth对话框,因此这是一个使用FB.Login的示例,其中包含用户接受/拒绝权限时的回调。

FB.login(function(response) 
  {
      if (response.authResponse)
      {
          // user has granted permissions
      } 
      else
      {
          // user did not grant permissions
      }
  }, 
  {
      scope: 'email, user_about_me, user_likes'
  }
);