Disqus 与 PHP API 数据同步
http://docs.disqus.com/help/58/
有人可以展示如何获取那个工作?我不确定我是否理解如何使用现实生活中显示的代码。
我已经创建了一个数据库并下载了 PHP API,但即使使用上面链接的文档,我也不知道如何使用它。
我想定期保存和检查帖子,我需要使用 CRON,但如果我能弄清楚如何使用 API,我自己应该能够得到它。
谢谢
Fatal error: Uncaught exception 'Exception' with message 'Missing required argument: forum'
^^这是我尝试使其与下面最基本的示例一起工作时遇到的错误:
$DisqusAPI = new DisqusAPI('my_api_key');
// query our MAX datestamp
$since = "SELECT MAX(nDA) FROM news";
$params = array('forum'=>'my_forum_name','since'=>(int)$since,'limit'=>100);
// fetch newer than posts from API
$posts = $DisqusAPI->forums->listPosts(json_decode($params));
// save posts locally
foreach ($posts as $post) {
//save($post);
}
http://docs.disqus.com/help/58/
Can someone show be howto get that working? I'm not sure I understand how to use the code shown in a real life context.
I've created a database and have downloaded the PHP API, but im not sure howto use it even with the documentation linked above.
I presume to save and check for the posts at regular intervals I'll need to use CRON, but I should be able to get that myself if I can figure out howto work with the API.
Thanks
Fatal error: Uncaught exception 'Exception' with message 'Missing required argument: forum'
^^ That's the error I get when I try to make it work with the most basic example below:
$DisqusAPI = new DisqusAPI('my_api_key');
// query our MAX datestamp
$since = "SELECT MAX(nDA) FROM news";
$params = array('forum'=>'my_forum_name','since'=>(int)$since,'limit'=>100);
// fetch newer than posts from API
$posts = $DisqusAPI->forums->listPosts(json_decode($params));
// save posts locally
foreach ($posts as $post) {
//save($post);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本上他们所说的是,您需要创建一个数据库表(或其他一些数据存储)来保存从 Disqus 下载到您的网站的评论。它们为数据库表提供了推荐的架构。
然后,您可以使用他们的 API 客户端(您下载的那个)来提取评论,循环遍历它们并将它们存储在您的数据库中。他们为您提供指导,确保交互简洁,不要一次下载所有评论,而只下载您可能尚未下载的评论。
您可能需要下载 Wordpress 插件并通读它,以获取使用客户端的完整实际应用程序。
Basically what they're saying is you need to create a database table (or some other datastore) to hold comments you download from Disqus to your site. They provide a recommended schema for a database table.
You would then use their API client (the one you downloaded) to pull down the comments, loop over them and store them in your database. They give you guidelines to make sure the interaction is lean by not downloading all the comments at once, and only downloading ones you may not have downloaded yet.
You might want to download the Wordpress plugin and read through it for a complete practical application using the client.
在此示例中,他们将数据作为 JSON 对象发送。您将其作为
数组
发送。你认为这可能是问题所在吗?In the example in there, they're sending the data as a JSON object. You're sending it as an
array
. Do you think that might be the problem?问题在于代码为
Exception
属性分配了不正确的数据类型。在简要浏览了 github 上的 DisqusAPI 之后,我相信我有 找到有问题的代码行。从您的错误消息看来,
$data->code
或$data->response
不是有效类型,可能是array
或一个对象
。根据您的示例、错误消息和 DisqusAPI 代码,这似乎是罪魁祸首。Well, the problem is that the code is assigning an incorrect data type to an
Exception
property. After taking a brief look through the DisqusAPI on github I believe I have found your offending line of code.From your error message it appears that
$data->code
or$data->response
is not a valid type, possibly being anarray
or anobject
. Based on your example, the error message and the DisqusAPI code this appears to be the likely culprit.