anime-db / shikimori-browser-bundle
Anime DB 目录的 Shikimori 插件
v2.3.0
2017-08-01 13:52 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.3
Requires (Dev)
- phpunit/phpunit: ~4.8
- satooshi/php-coveralls: ^1.0
- scrutinizer/ocular: ~1.3
- symfony/config: ~2.7|~3.0
- symfony/dependency-injection: ~2.7|~3.0
- symfony/expression-language: ~2.7|~3.0
- symfony/http-kernel: ~2.7|~3.0
README
Shikimori.org API 浏览器
在此处阅读 API 文档:http://shikimori.org/api/doc
安装
使用 Composer 非常简单,运行
composer anime-db/shikimori-browser-bundle
配置
anime_db_shikimori_browser: # API host # As a default used 'https://shikimori.org' host: 'https://shikimori.org' # Prefix for API resurces # As a default used '/api/' prefix: '/api/' # HTTP User-Agent # No default value client: 'My Custom Bot 1.0'
使用方法
首先获取浏览器
$browser = $this->get('anime_db.shikimori.browser');
列出动漫 (文档)
$animes = $browser->get('animes', ['query' => ['limit' => 10]]);
或
$animes = $browser->get('animes?limit=10');
标记所有消息为已读 (文档)
$response = $browser->post('messages/read_all');
更新消息 (文档)
$response = $browser->patch('messages/12', [ 'body' => [ 'message' => [ 'body' => 'blablabla', ], ], ]);
更新评论 (文档)
$response = $browser->put('comments/8', [ 'body' => [ 'message' => [ 'body' => 'blablabla', ], ], ]);
删除消息 (文档)
$browser->delete('messages/12');
捕获异常
use AnimeDb\Bundle\ShikimoriBrowserBundle\Exception\NotFoundException; try { $content = $browser->get('animes/1'); } catch (NotFoundException $e) { // anime not found } catch (\Exception $e) { // other exceptions }
您可以自定义请求选项。请参阅 Guzzle 文档。
许可证
此包位于 MIT 许可证 下。请参阅文件中的完整许可证:LICENSE