Home Counting Facebook comments for *multiple* URLs (Facebook JS SDK) returns 0
Reply: 0

Counting Facebook comments for *multiple* URLs (Facebook JS SDK) returns 0

user1670 Published in March 22, 2018, 12:05 am

I'm trying to build a blog system which integrates Facebook SDK for the comments—it's all fine apart from showing the count of comments in the blog list.


<h1>Getting count of Facebook comments on example.com</h1>
<span class="comment"><fb:comments-count href="https://example.com"></fb:comments-count></span>


window.fbAsyncInit = function() {
    appId            : '123',
    autoLogAppEvents : true,
    xfbml            : true,
    version          : 'v2.11'

(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 = "https://connect.facebook.net/en_US/sdk.js";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

Returns: 28

The issue is returning the count of comments for multiple URLs.

Getting the comment count for one URL is easy and works here:


However as soon as I try to add another URL to get the comment count for it just returns 0 as the count for all:


To make it even stranger, if I remove the appId from the JS FB SDK api it works, but then that would break the rest of the system:


Am I doing something wrong, I've tried reading the FB developer documentation for this, but it simply provides the one line of code.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298767 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO