2012-09-13 68 views
-2

我可以登錄,但我需要得到的accessToken,使其他API如得到朋友等可以被調用。登錄後如何獲取Facebook accessToken?

方法getLoginStatus被調用,但沒有進入success塊的響應。

這裏是我的代碼:

$(document).ready(function() { 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: <<My appId>>, // App ID 
      status: true, // check login status 
      cookie: true, // enable cookies to allow the server to access the session 
      xfbml: true, // parse XFBML 
      oauth: true 
     }); 
     FB.getLoginStatus(function(response){ 
      alert('response='+response); 
     }); 
     window.setTimeout(checkLogStatus, 1000); 
     function checkLogStatus(){ 
      alert("check"); 
      // fetch the status on load 
      FB.getLoginStatus(function(response){ 
       alert('response='+response); 
      }); 
     } 
    }; 

    // Load the SDK Asynchronously 
    (function(d){ 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 
}); 

回答

0

我需要得到的accessToken

的SDK通常是能夠處理的訪問令牌自身很好 - 包括它的任何自動向API發送請求,而無需手動執行某些操作。

所以對我來說這並不是很清楚,你在這裏實際存在/試圖解決什麼問題。