madahost / imdb-api
可以获取电影数据和搜索结果的IMDB API
v1.0.0
2024-02-05 04:44 UTC
Requires
- php: >=7.1
- madahost/php-html-parser: dev-main
- predis/predis: ^2.2
- tmarois/filebase: ^1.0
Requires (Dev)
- php-coveralls/php-coveralls: 2.5.2
- phpunit/phpunit: 9.5.16
README
PHP IMDB-API,可以获取电影数据和搜索结果。
安装
使用 composer 安装最新版本。
$ composer require madahost/imdb-api:dev-main
用法
// Assuming you installed from Composer: require "vendor/autoload.php"; use madahost\Imdb; $imdb = new Imdb; // Search imdb // -> returns array of films and people found $imdb->search("Apocalypse"); // Get film data // -> returns array of film data (title, year, rating...) $imdb->film("tt0816692");
选项
$imdb = new Imdb; // Options are passed as an array as the second argument // These are the default options $imdb->film("tt0816692", [ 'cache' => true, 'curlHeaders' => ['Accept-Language: en-US,en;q=0.5'], 'techSpecs' => true, ]); $imdb->search("Interstellar", [ 'category' => 'all', 'curlHeaders' => ['Accept-Language: en-US,en;q=0.5'], ]);
最佳匹配
如果您不知道电影的imdb-id,可以输入搜索字符串。这将搜索imdb,并使用第一个结果作为获取数据的电影。
请注意,这会比仅输入ID花费更长的时间,因为它需要首先搜索imdb,然后才能获取电影数据。
// Searches imdb and gets the film data of the first result // -> will return the film data for 'Apocalypse Now' $imdb->film("Apocalypse");
功能
电影数据
- Title
- Genres
- Year
- Length
- Plot
- Rating
- Rating Votes (# of votes)
- Poster
- Trailer
- id
- link
- Cast
- actor name
- actor id
- character
- avatar
- avatar_hq (high quality avatar)
- Technical Specs
搜索
搜索IMDB,返回包含电影、人员和公司的数组
- Films
- id
- title
- image
- People
- id
- name
- image
- Companies
- id
- name
- image
依赖项
所有依赖项都由
composer
自动管理。