這似乎是一個持續的問題,其他人以及我..但即使在「問題,可能已經有你的答案」發佈時,我仍然無法得到這個工作。使用PHP獲取面板評論數
我真正想要的是通過傳遞文章的標識符(或URL)給定文章的評論數。
我從github上下載了這個:https://github.com/disqus/disqus-php
跟着這裏的第一個答案:How to get Disqus comment count for a page using Disqus PHP API?這似乎最接近我試圖實現。這使我這個遠:
<?php
require_once('scripts/disqusapi/disqusapi.php');
$disqus = new DisqusAPI('secret_key');
$page_with_comments = $disqus->posts->details(array('thread'=>"LINK-IDENTIFIER"));
$comment_count = $page_with_comments->posts;
?>
當我做到這一點,但是我正在此錯誤:
Fatal error: Uncaught exception 'Exception' with message 'Missing required argument: post' in /home/mugheads/public_html/scripts/disqusapi/disqusapi.php:82 Stack trace: #0 /home/mugheads/public_html/test.php(4): DisqusResource->__call('details', Array) #1 /home/mugheads/public_html/test.php(4): DisqusResource->details(Array) #2 {main} thrown in /home/mugheads/public_html/scripts/disqusapi/disqusapi.php on line 82
此錯誤表明您可以不再使用「線」來檢索JSON需要..我無法找到ID Disqus使用的帖子,因爲使用「post」就像錯誤描述只接受一個整數。
如果有人知道更簡單的方法,或絕對有效的方式,請分享!
任何幫助將不勝感激!
也許用'post'取代'thread' – Augwa
感謝您的回覆!當我這樣做,它告訴我發佈必須是一個整數..但沒有辦法我的知識使用身份證的,而不是文字來識別帖子。 – Zephni