canihavesomecoffee / thetvdbapi
PHP 实现了 TheTVDb API 的第 4 版。
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^5.4|^6.0
- symfony/property-info: ^5.4|^6.0
- symfony/serializer: ^5.4|^6.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- dev-master
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0.beta9
- 2.0.0.beta8
- 2.0.0.beta7
- 2.0.0.beta6
- 2.0.0.beta5
- 2.0.0.beta4
- 2.0.0.beta3
- 2.0.0.beta2
- 2.0.0.beta1
- 2.0.0.beta
- 1.3.0
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/symfony/property-info-tw-5.4tw-6.0tw-7.0
- dev-dependabot/composer/symfony/property-access-tw-5.4tw-6.0tw-7.0
- dev-dependabot/composer/symfony/serializer-tw-5.4tw-6.0tw-7.0
This package is auto-updated.
Last update: 2024-09-18 05:00:48 UTC
README
这是 thetvdb.com 网站的 API 客户端。它使用的是 theTVDb API 的第 4 版。为了能够访问此 API,您必须首先在 theTVDb 上注册并获取项目密钥。
API 密钥注册
要使用此 PHP 包,您需要从 thetvdb.com 网站请求 API 密钥:[https://thetvdb.com/dashboard/account/apikeys](https://thetvdb.com/dashboard/account/apikeys)。
我们有两种 API 访问模式,两者都提供资金,使我们能够继续运行和改进网站。第一种是我们协商许可模式,允许商业公司与我们协商访问。第二种是用户订阅模式,允许最终用户订阅以访问 API。我们保留在任何时候不预先通知更改我们的接口、费用或许可条款的权利。
要创建 API 密钥,请创建账户并访问仪表板上的 API 密钥页面。
安装
使用 composer 安装此包
$ composer require canihavesomecoffee/thetvdbapi
文档
官方 API 文档可以在以下位置找到:[https://thetvdb.github.io/v4-api/](https://thetvdb.github.io/v4-api/)。
有关 API 的使用示例,请参阅示例文件夹。
API 全局翻译
您可以将主要语言和次要(回退)语言传递给 API 构造函数。
例如,如果您想使用荷兰语,但没有荷兰语翻译,则可以按以下方式设置
$theTVDbAPI = new \CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI("nld", "eng");
默认情况下,主要语言设置为英语,没有回退语言。
身份验证
$theTVDbAPI = new \CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI();
// Obtain a token. Optionally you can pass a user pin through as well.
$token = $theTVDbAPI->authentication()->login($apiKey);
// Set the token
$theTVDbAPI->setToken($token);
路由
TheTVDbAPI
提供了对 API 提供的相同路由的访问。以下列出了几个使用示例
身份验证
$theTVDbAPI->authentication()->login($apiKey);
// or in case it's a project with user-specific subscriptions
$theTVDbAPI->authentication()->login($apiKey, $pin);
语言
$theTVDbAPI->languages()->all();
剧集
$theTVDbAPI->episodes()->simple(6347388);
$theTVDbAPI->episodes()->extended(8366715);
$theTVDbAPI->episodes()->translations(8366715, "nld");
系列
$theTVDbAPI->series()->list();
$theTVDbAPI->series()->simple(280258);
$theTVDbAPI->series()->extended(280258);
$theTVDbAPI->series()->translate(280258);
$theTVDbAPI->series()->episodes(280258); // Paginated
$theTVDbAPI->series()->allEpisodes(280258); // All episodes, translated
搜索
$theTVDbAPI->search()->search("Ideale");
$theTVDbAPI->search()->search("Ideale", ["year" => 2014]);
$theTVDbAPI->search()->search("Ideale Wereld", ["type" => "series"]);
更新
获取最近更新的实体列表
$now = new DateTime();
$now->sub(new DateInterval("PT2H"));
$theTVDbAPI->updates()->query($now);
一些包装方法可用于限制结果
$now = new DateTime();
$now->sub(new DateInterval("PT2H"));
$theTVDbAPI->updates()->fetchSerieUpdates($now);
$theTVDbAPI->updates()->fetchEpisodeUpdates($now);
艺术作品
$theTVDbAPI->artwork()->simple(62001533);
$theTVDbAPI->artwork()->extended(62001533);
$theTVDbAPI->artwork()->statuses();
$theTVDbAPI->artwork()->types();
贡献
虽然目标是提供一个现成的 API,但可能有些内容缺失或过时。如果您认为缺少某些内容,或者您想添加某些内容,请随意提出问题,或者更好的是,提交一个修复或改进的 Pull Request (PR)。我们很乐意接受 PR 以改进此客户端 API。