How to get Disqus comment count for a page using Disqus PHP API?

梦想与她 提交于 2019-12-12 04:37:31

问题


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.


回答1:


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));



回答2:


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.



来源:https://stackoverflow.com/questions/23630150/how-to-get-disqus-comment-count-for-a-page-using-disqus-php-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!