【问题标题】:Facebook OAuth2.0 ImplementationFacebook OAuth2.0 实现
【发布时间】:2011-07-29 23:10:20
【问题描述】:

我是 Facebook 实施的新手。请帮助我通过使用 OAuth2.0 的新 all.js 实现此代码

 window.addEvent('domready', function(){     
 FB.init("<%= ConfigurationManager.AppSettings["ApiKey"].ToString() %>", 
         "/xd_receiver.htm",
         {"ifUserConnected": update_user_is_connected,
          "ifUserNotConnected": update_user_is_not_connected,
          "doNotUseCachedConnectState":"true"});
});

【问题讨论】:

    标签: javascript facebook oauth-2.0


    【解决方案1】:

    这个问题并没有真正解释太多,但猜测一下,应该这样做(我对旧的api不熟悉,所以我不知道你是否必须将任何参数传递给update_user_is_connected/ not_connected,进行相应修改):

    window.fbAsyncInit = function() {
        FB.init({
            appId  : '<%= ConfigurationManager.AppSettings["ApiKey"].ToString() %>',
            status : true, // check login status
            cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true,  // parse XFBML
            channelUrl  : 'http://www.yourdomain.com/channel.html', // Custom Channel URL
            oauth : true //enables OAuth 2.0
        });
    
        FB.getLoginStatus(function(response) {
            if (response.authResponse) update_user_is_connected();
            else update_user_is_not_connected();
        });
    
        // This will be triggered as soon as the user logs into Facebook (through your site)
        FB.Event.subscribe('auth.login', function(response) {
            update_user_is_connected();
        });
    };
    

    您可以在以下位置阅读更多内容:

    http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-12
      • 2014-04-02
      • 1970-01-01
      • 2019-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多