我正在尝试通过 javascript sdk 获取当前用户登录状态,但出现以下错误:
在调用 FB.init() 之前调用 FB.getLoginStatus()
这是我的代码:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '000000000000000000', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
console.log(FB.getLoginStatus); //THIS DOESN'T WORK!!
};
// 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));
</script>
有任何想法吗?