I've a problem with FB JS SDK.
I'm trying to do a request to get the fan_count of a facebook page node.
Here is my code from my html file into the body :
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.5'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
And when I'm using this on my js app, I use it :
init();
function init() {
var id_fb = "l214.animaux";
while (true) {
console.log("je suis ici");
FB.api(
'/' + id_fb + '/',
'GET',
{"fields":"fan_count"},
function(response) {
alert(response.fan_count);
}
);
}
}
But the error is that FB is not defined. Any suggestions ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…