html - 我的网站上不显示“赞”按钮

标签 html facebook facebook-graph-api facebook-javascript-sdk facebook-like

我正在尝试使用 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/

相关文章:

html - 如何使用 Selenium 中的变量检查属性值

html - IE 中的表格宽度

Facebook API 对象点赞限制、点赞数和分享数

javascript - 我如何向玩家 friend 的时间线发送消息

php - 刷新页面后将所选值保留在下拉列表中

html - CSS 列表高度问题

html - Twitter 卡片/打开图表/Apple 触摸图标/每一页?

php - 将 jQuery 淡入或滚动效果应用于 Facebook Like Newsfeed

javascript - 潜在客户发掘的 Facebook webhook - 无法检索 Facebook 潜在客户广告

ios - Facebook 的 iOS 应用程序 : sharing via feed dialogue using a ‘web app’ results in cropped image