doufu5521 2012-10-06 13:32
浏览 35

使用带有查询字符串的facebook like按钮 - 就像按钮不起作用

I'm incorporating the facebook Like button and Comments API into my site (at long last). Now on my site I have one page that uses a query string to determine the correct content (my site has over 4000 entries which us this querystring). Thus to the user this one page appears like many, think of it like this...

productPage.php?productID=1234

Now I can add the comments API with no problems, it can distinguish the difference in URL/querystring which is great. The Like button however just doesn't work. You click on it and it flickers and returns to how it was (it doesn't register the Like). I"m encoding the URL correctly (see below)

<?php
   $fbUrl = urlencode("https://" . $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']);
   // echo "this page is " .  $fbUrl;
?>

<script>

 window.fbAsyncInit = function() {
        FB.init({
          appId      : 'XXXXXXXXXXXXXXXXX', // App ID
          channelUrl : '//www.myURL.co.uk/channel.php', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true  // parse XFBML
        });

        // Additional initialization code here
      };

</script>

Oh I love this content....
<br><br>

<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&appId=205472122918257";
    fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));
</script>

<div class="fb-like" data-href="<?php echo $fbUrl; ?>" data-send="true" data-width="450" data-show-faces="false"></div>
<br><br>
and add a comment...
<br><br>
<div class="fb-comments" data-href="<?php echo $fbUrl; ?>" data-num-posts="2" data-width="470" data-colorscheme="dark"></div>

I've spent a few hours on this and noticed that others have suffered from this too, however no one seems to have a solution. Whilst I'm trawling the web trying to find a solution has anyone got a work around or experience of this issue?

  • 写回答

2条回答 默认 最新

  • 普通网友 2013-06-26 19:14
    关注

    Have you checked your page with the open-graph debugger?

    https://developers.facebook.com/tools/debug

    评论

报告相同问题?

悬赏问题

  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题