adrenth / thetvdb2
thetvdb.com 的 API v2 客户端
6.2.2
2024-06-10 10:47 UTC
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^6.0|^7.0
- illuminate/support: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- symfony/serializer: ^4.0|^5.0|^6.0|^7.0
Requires (Dev)
- phpstan/phpstan: ^1.4
README
这是一个 thetvdb.com 网站的 API 客户端。它使用 RESTful API,您需要注册才能使用此包。
API 密钥注册
要使用此 PHP 包,您需要从 thetvdb.com 网站请求 API 密钥: http://thetvdb.com/?tab=apiregister。
请遵循以下指南
- 如果您将在商业产品或网站上使用 API 信息,您必须通过电子邮件 scott@thetvdb.com 联系我们并等待授权后才能使用 API。但是,您可以在公开发布之前使用 API 进行开发和测试。
- 如果您有一个公开可用的程序,您必须通知您的用户此网站,并要求他们如果可能的话帮助贡献信息和艺术作品。
- 您必须熟悉我们的数据结构,这些结构在wiki文档中有详细说明。
- 您必须不要对每个用户进行不必要的请求。这意味着不要下载所有内容(如果需要,我们将提供数据库)。请与我们的服务器友好相处。
- 您必须不要在没有使用文档化的 API 方法的情况下直接访问我们的数据。
- 您必须确保您的账户信息中的电子邮件地址是最新的和准确的,以防我们需要联系您有关您的密钥(我们和其他人一样讨厌垃圾邮件,所以我们永远不会将您的电子邮件地址发布给其他人)。
- 请随时联系我们,并要求对我们网站和/或 API 进行更改。我们将乐意考虑所有合理的建议。
来源:thetvdb.com
安装
使用 composer 安装此包
$ composer require adrenth/thetvdb2
要求
至少 PHP 7.4
文档
官方 API 文档可以在以下位置找到: https://api.thetvdb.com/swagger。
身份验证
$client = new \Adrenth\Thetvdb\Client(); $client->setLanguage('nl'); // Obtain a token $token = $client->authentication()->login($apiKey, $username, $userKey); $client->setToken($token); // Or refresh the token $client->refreshToken();
扩展
Client
有几个扩展。以下列出了几个使用示例
身份验证
$client->authentication()->login($apiKey, $username, $userKey); $client->authentication()->refreshToken();
语言
$client->languages()->all(); $client->languages()->get($languageId);
剧集
$client->episodes()->get($episodeId);
系列
$client->series()->get($seriesId); $client->series()->getActors($seriesId); $client->series()->getEpisodes($seriesId); $client->series()->getImages($seriesId); $client->series()->getLastModified($seriesId);
搜索
$client->search()->seriesByName('lost'); $client->search()->seriesByImdbId('tt2243973'); $client->search()->seriesByZap2itId('EP015679352');
更新
获取最近更新的系列列表
$client->updates()->query($fromTime, $toTime);
用户
$client->users()->get(); $client->users()->getFavorites(); $client->users()->addFavorite($identifier); $client->users()->removeFavorite($identifier); $client->users()->getRatings(); $client->users()->addRating($type, $itemId, $rating); $client->users()->updateRating($type, $itemId, $rating); $client->users()->removeRating($type, $itemId);
电影
$client->movies()->get(78398); $client->movies()->getUpdates();
响应数据
每个响应对象都有一个 getData()
方法,该方法可能包含一组对象。
例如
// Get all available languages $languageData = $client->languages()->all(); // Returns a LanguageData instance $languages = $languageData->getData()->all(); array:23 [▼ 0 => Language {#26 ▼ -values: array:4 [▼ "id" => 27 "abbreviation" => "zh" "name" => "中文" "englishName" => "Chinese" ] } 1 => Language {#19 ▶} 2 => Language {#30 ▶} 3 => Language {#21 ▶} // .. ];
贡献
欢迎加入我们,创建一个与全新的 TheTVDB.com RESTful API 兼容的稳定版本。