escapeboy / disqus
Laravel 4 中使用 Disqus API 的简单示例
dev-master
2014-06-24 16:58 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-17 00:48:25 UTC
README
用于与 Disqus 一起工作的简单包
安装
使用 composer
{
...
"require": {
"escapeboy/disqus": "dev-master"
}
}
在 app/config/app.php
中注册
'providers' => array( 'Escapeboy\Disqus\DisqusServiceProvider', )
配置
发布配置文件
php artisan config:publish escapeboy/disqus
在 app/config/packages/escapeboy/disqus/config.php
中编辑配置文件
return array( 'api_key' => '', // your disqus api key 'api_secret' => '', // your disqus secret 'api_version' => '3.0', // disqus API version used. Do not change it 'cache_time' => 60, // cache time in minutes used to cache results 'forum' => '' // your disqus forum (shortname) );
用法
例如,我们想从 API 中获取一些线程的信息。我们想获取 "thread" 部分,子部分 "details"。我们提供 "thread:link"(可以使用 "thread:ident" 或 "thread")。它将返回 JSON 格式的数据。更多信息请查看:http://disqus.com/api/docs/threads/details/
// Disqus::get($section, $method, $params=array() $thread = Disqus::get('threads', 'details', array('thread:link' => 'http://thread_url'));
向 Disqus 发送数据
Disqus::post('posts', 'create', array('message' => 'Yo! Nice thread!', 'thread' => 12));
一些简短函数
$comment_count = Disqus::commentsCount('http://thread_url'); // returns integer of comments count for given url
... 更多函数将在下一版本中推出