Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook like button not displaying :: FB.getLoginStatus() called before calling FB.init()

I just want a basic facebook like button on my site. I follow the instructions per facebooks site (http://developers.facebook.com/docs/reference/plugins/like/). I tried the HTML5, XFBML, and iFrame ways, no joy on either. So I thought maybe it's something with my site interfering. So I created a bare-bones html page like below and it still gives me the FB.getLoginStatus() called before calling FB.init() error.

<html>
<body>
<div id="fb-root"></div>
<script>(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/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/[mypage]" data-send="false" data-width="450" data-show-faces="false"></div>
</body>
</html>

UPDATE: I removed all that stuff above went back to the iFrame only method and it works, but only in Firefox. Chrome and IE9 I still get nothing but no errors reported. Why is this line below only working in FireFox (obviously the [myPage] part is swapped out)?

 <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2F[myPage]&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>
like image 562
gfrobenius Avatar asked Sep 20 '12 14:09

gfrobenius


3 Answers

Not sure the App ID is the problem here. I'm also experiencing this strange error message, and I'm just including standard code for FB Like Button social plugin, provided by FB developer page.

I then went again through the plugin configuration page and copied again code, which anyway was unchanged noticing little difference in the HTML part of generated code (was a <fb:like> tag, now is <div class="fb-like">). Anyway error still persists.

Then I just realised that in a few weeks FB Like Button will migrate permanently to Built-in Like action for Open Graph, and if I got it correctly you have to create an App ID anyway.

At that point the error might just disappear. And it seems difficult that anyone will fix anything on something that's going to disappear in a few weeks.

HTH

like image 80
superjos Avatar answered Oct 20 '22 22:10

superjos


Are you testing it locally? After debugging and searching quite a bit myself, I decided to test it on a webserver of mine, and voila, it worked! :)

like image 24
Johny Skovdal Avatar answered Oct 20 '22 22:10

Johny Skovdal


On the Facebook Developer page where we obtain the script for the Like Button, Facebook says nothing of needing to implement the init() as well (which would presumably solve this problem, but what WOULD you use as the APP ID if you also called the init() function ??).

And an APP ID is not needed anyway for the Like Button to work. I believe that Facebook is just giving us the Like Button code -- even though the absence of the init() function is going to cause this js error (but apparently the init() is not actually needed!).

This seems like a shortcoming in FB's deployment of the Like Button API.

like image 1
Jim O. Avatar answered Oct 21 '22 00:10

Jim O.