【问题标题】:Call function after oauth successoauth成功后调用函数
【发布时间】:2011-10-27 21:39:29
【问题描述】:

当 Facebook 已被授权时,我如何调用函数??

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

???

【问题讨论】:

    标签: facebook authentication oauth-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.');
        }
      }
    );
    

    【讨论】:

      【解决方案2】:

      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'
        }
      );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-13
        • 2016-10-07
        • 2012-07-27
        • 2015-02-08
        相关资源
        最近更新 更多