I want to check if a user is logged-in in facebook using the Facebook JavaScript JDK and jQuery. But even with a timeout of 10 seconds I get this error message:
FB.getLoginStatus() called before calling FB.init().
Here is my code:
<script type="text/javascript" src="/js/jquery-1.2.3.pack.js" />
<div id="fb-root"></div>
<script src="http://connect.facebook.net/de_DE/all.js"> </script>
<script type="text/javascript">
jQuery('document').ready(
function(){
FB.init({
status : true,
cookie : true,
xfbml : true
});
setTimeout(function(){
FB.getLoginStatus(function(response) {
if (response.session) {
jQuery('div#likeButtonWhatsThisText').remove();
}
});
}, 10000)
}
)
</script>
Any ideas on how to get this work?
thanks christian
Hi I think you are calling fb.init without passing your application ID. It should be like this
FB.init({
appId: "Your API ID",
status: true,
cookie: true,
xfbml: true
});
I hope this will work.
Not a pro at this but have you tried:
FB.Event.subscribe('auth.login', yourFunc);
And yourFunc should have one arg (response) where you check:
response.status == 'connected'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With