首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Facebook OAuth2.0实现

Facebook OAuth2.0实现
EN

Stack Overflow用户
提问于 2011-07-29 22:31:27
回答 1查看 470关注 0票数 0

我对Facebook的实现还是个新手。请帮助我使用OAuth2.0通过新的all.js实现这段代码

代码语言:javascript
复制
 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"});
});
EN

回答 1

Stack Overflow用户

发布于 2011-07-29 23:10:21

这个问题并没有真正解释太多,但猜测一下,应该是这样的(我不熟悉旧的api,所以我不知道您是否必须向update_user_is_connected/ not _connected传递任何参数,请相应地修改它):

代码语言:javascript
复制
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/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6874718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档