anime-db/shikimori-browser-bundle

Anime DB 目录的 Shikimori 插件

v2.3.0 2017-08-01 13:52 UTC

This package is auto-updated.

Last update: 2024-09-15 18:52:09 UTC


README

Shikimori

Latest Stable Version Total Downloads Build Status Coverage Status Scrutinizer Code Quality SensioLabs Insight StyleCI License

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