首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我的网站上放置Like按钮的2个问题

在我的网站上放置Like按钮的2个问题
EN

Stack Overflow用户
提问于 2012-09-18 22:33:01
回答 1查看 103关注 0票数 2

我是一个网站的PHP开发人员,最近用较新的代码示例替换了Sharer.php代码。Like按钮可以正常显示,但当您单击它时,弹出窗口只显示一两秒,然后消失。此外,弹出窗口中也没有显示描述--只有URL。Like按钮代码包含在用户可以隐藏的DIV容器中(使用JQuery),页面上有AJAX,可以每分钟自动查询表一次,以刷新屏幕上的计数器。

以下是一些代码片段,以备不时之需,任何帮助都将不胜感激:

代码语言:javascript
复制
<meta property="og:title" content="FourFreedomsBlog - Romney/Ryan: Channeling the  inner McCain" />
<meta property="og:description" content="The Romney/Ryan campaign is evoking an eerie recollection of the McCain campaign of 2008: trust us - you'll get the details AFTER we're elected." />
<meta property="og:url" content="http://www.fourfreedomsblog.com/Blog.php?Act=ViewBlogPost&amp;BlogID=2090" />
<meta property="og:image" content="http://www.FourFreedomsBlog.com/images/4Fv3.0.gif" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="FourFreedoms Blog" />
<meta property="fb:admins" content="14194340826" />

<div class="ShareThisContainer">

<div class="FoldingMenu">
  <h4><button id="showShareThis" class="ButtonHide" /></button><span name="" id="">Share This!</span></h4>

  <div id="SharePane" class="TogPane ItemHide">

    <table class="ShareThis">
      <tr>
        <td colspan=8>

          <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%3A%2F%2Fwww.FourFreedomsBlog.com%2FBlog.php?Act=ViewBlogPost&BlogID=2090" data-send="true" data-width="320" data-show-faces="true"></div>

        </td>
      </tr>
    </table>

  </div><!-- id=SharePane -->

</div><!-- class=FoldingMenu -->
</div><!-- class=ShareThisContainer -->
EN

回答 1

Stack Overflow用户

发布于 2012-09-18 22:49:44

<div class="fb-like" data-href="http%3A%2F%2Fwww.FourFreedomsBlog.com%2FBlog.php?Act=ViewBlogPost&BlogID=2090" …

首先,不要在这里对data-href参数的值进行URL编码。

其次,不要在你的域名中使用大写字母- Facebook scraper在带有大写字母的域名上失败-比较

https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.FourFreedomsBlog.com%2FBlog.php%3FAct%3DViewBlogPost%26BlogID%3D2090

vs

https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.fourfreedomsblog.com%2FBlog.php%3FAct%3DViewBlogPost%26BlogID%3D2090

最后,修复调试工具显示的错误:

对象无效值:类型为“”网站“”的URL“”http://www.fourfreedomsblog.com/Blog.php?Act=ViewBlogPost&BlogID=2090“”处的对象无效,因为无法将属性“”fb:admins“”的给定值“”14194340826“”分析为类型“”fbid“”。“”

14194340826是一个Facebook群组的id --但是群组不能是任何东西的“管理员”,只有普通的用户帐户可以。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12479153

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档