我正在尝试使用 Facebook 的点赞按钮进行一些测试。我想将其添加到我的网站,但它不显示。我正在使用 Mac OS 的 Mamp 在本地测试它。我在这里添加我的代码;你能帮我找出错误吗?我一直在尝试使用 FB SDK 和 iframe,但它们没有显示任何内容。
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '145033796136', // App ID from the app dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<h1>Rumba Babylon</h1>
<section>
here probably show content
</section>
<aside>
<h1>SOCIAL PLUGINS</h1>
<div class="fb-like" data-href="https://www.facebook.com/enbodega?fref=ts"data-send="false" data-layout="box_count" data-width="450" data-show-faces="false"></div>
</aside>
<script src="js/jquery.js"></script>
<script src="js/main.js"></script>
</body>
最佳答案
尝试使用类似插件的 XFBML 版本:
替换
<div class="fb-like" data-href="https://www.facebook.com/enbodega?fref=ts"data-send="false" data-layout="box_count" data-width="450" data-show-faces="false"></div>
至
<fb:like href="https://www.facebook.com/enbodega?fref=ts" send="false" layout="box_count" width="450" show_faces="false"></fb:like>
如果仍然不起作用,请在 FB.init
之后添加以下内容:
FB.XFBML.parse();
关于html - 我的网站上不显示“赞”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16750546/