2011-07-29 75 views
0

我是Facebook新手。請幫我使用OAuth2.0的Facebook OAuth2.0實現

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

回答

1

的問題並沒有真正解釋太多,以實施通過新all.js這個代碼,但猜測一點點,這樣的事情應該做的(我不熟悉舊的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/