2012-09-13 67 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发送请求,而无需手动执行某些操作。

所以对我来说这并不是很清楚,你在这里实际存在/试图解决什么问题。