FB评论不会更新评论计数

时间:2014-02-05 02:53:47

标签: facebook count comments

我在我的网站上使用Facebook评论,它工作正常,但只有在添加评论后才会更新计数。当我尝试删除评论时,评论已删除,但计数未更新。

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


 <div id="facebook">
                <fb:comments-count href='http://floral-style.ru/blog/novogodnie-kompozicii-v-galeree-butikov-Mon-Plaisir-DEKAPT-Ermenegildo-Zegna'></fb:comments-count>
                <fb:comments width='850' colorscheme='light' href='http://floral-style.ru/blog/novogodnie-kompozicii-v-galeree-butikov-Mon-Plaisir-DEKAPT-Ermenegildo-Zegna' xid='99' order-by="reverse_time"/>

            </div>

2 个答案:

答案 0 :(得分:0)

试试这个:

<div class="fb-comments-count" data-href="http://facebook.com">0</div>

将data-href替换为您的网址。

服务器响应后,将替换“0”零。

答案 1 :(得分:0)

试试这个:

HTML - 将其放在<body>标记之后:

<span class='comment-count' id='facebook-comment-count'>
   <fb:comments-count href='YOUR_URL_HERE'/>
</span>

JQuery / Javascript - 将其放在</body>标记之前:

<script type='text/javascript'>       
      $(window).load(function(){
        //UPDATE NUMBER OF COMMENTS
        var comment_callback = function(response) {
            FB.XFBML.parse(document.getElementById("facebook-comment-count"));
        };
        //Call comment_callback function when the comments are created. 
        FB.Event.subscribe('comment.create', comment_callback);
        //Call comment_callback function when the comments are removed.
        FB.Event.subscribe('comment.remove', comment_callback);
      });
</script>