问题
I looked at previous asked questions about the facebook like button and didnt see anything that was wrong with my code. Here is what I have:
<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>
</body>
回答1:
After adding the code for initializing the Facebook's Javascript SDK you also have to add the code to display the Like button at the required place. The generic code for it is
<div class="fb-like" data-send="true" data-width="450" data-show-faces="true">
</div>
If you want you can further customize it by checking documentation here.
回答2:
Had the same problem, once I published the page, the like buttons showed up
facebook page : settings : Page Visibility : Page published
(the page was "unpublished" by default even after I did publish it for the first time)
回答3:
I know topic is old but still coming up in searches. Here's the initialization code I used:
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Important:
- By default Facebook auto-configuration tool (https://developers.facebook.com/docs/plugins/follow-button) does not prepend "HTTPS" when exporting the js.src element.
- If testing this on localhost host you will run into problems with the button visibility (c.f. v2.9) Either use a https tunnel service such as ngrok or deploy to valid https server.
回答4:
Adding version to the url js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11";
helped in my case.
来源:https://stackoverflow.com/questions/16207054/my-facebook-like-button-is-not-showing-up