0
votes

How can we get Disqus comment count for a specific page using Disqus PHP?

require_once('disqusapi/disqusapi.php');
$disqus = new DisqusAPI('sec_key');

Above snippet can be used to initialize the API object. What method to be called if a I have URL of a page in my website?

All my search leads to JavaScript samples to get comment count.

Thanks.

2
From the git page it seems you just chain the api calls?! Eg: forums/listPosts.json becomes $disqus->forums->listPosts(), and so on.Yoshi

2 Answers

2
votes

Just access any of the methods provided by the API:

require_once('disqusapi/disqusapi.php');
$disqus = new DisqusAPI('sec_key');
$page_with_comments = $disqus->posts->details(array('thread'=>THREAD_IDENTIFIER));
$comment_count = $page_with_comments->posts;

Or get a list of most popular posts:

$popular_pages = $disqus->threads->listPopular(array('forum'=>YOUR_SHORTNAME));
-1
votes

I am not clear about your question.

You can get the thread details using following API https://disqus.com/api/3.0/threads/details.json.

response->posts is comment count for that page.