|
1 | | -imdb-api |
| 1 | +# PHP IMDB API |
| 2 | +PHP IMDB-API that can fetch film data and search results. |
| 3 | + |
| 4 | + |
| 5 | +## Install |
| 6 | +Install the latest version using [composer](https://getcomposer.org/). |
| 7 | + |
| 8 | +``` |
| 9 | +$ composer require hmerritt/imdb-api |
| 10 | +``` |
| 11 | + |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +### Film Data |
| 16 | +- Title |
| 17 | +- Year |
| 18 | +- Length |
| 19 | +- Rating |
| 20 | +- Poster |
| 21 | +- Plot |
| 22 | +- Cast |
| 23 | + - actor name |
| 24 | + - actor id |
| 25 | + - image |
| 26 | +- Technical Specs |
| 27 | + |
| 28 | +### Search |
| 29 | +Search IMDB to return an array of films, people and companies |
| 30 | + |
| 31 | + |
| 32 | +## Usage |
| 33 | +```php |
| 34 | +// Assuming you installed from Composer: |
| 35 | +require "vendor/autoload.php"; |
| 36 | +use hmerritt\Imdb\Imdb; |
| 37 | + |
| 38 | +$imdb = new Imdb(); |
| 39 | + |
| 40 | +// Search imdb |
| 41 | +// -> returns array of films and people found |
| 42 | +$imdb->search("Apocalypse"); |
| 43 | + |
| 44 | +// Get film data |
| 45 | +// -> returns array of film data (title, year, rating...) |
| 46 | +$imdb->film("tt0816692"); |
| 47 | +``` |
| 48 | + |
| 49 | +### Best Match |
| 50 | +If you do not know the imdb-id of a film, a search string can be entered. This will search imdb and use the first result as the film to fetch data for. |
| 51 | + |
| 52 | +> Note that this will take longer than just entering the ID as it needs to first search imdb before it can get the film data. |
| 53 | +
|
| 54 | +```php |
| 55 | +// Searches imdb and gets the film data of the first result |
| 56 | +// -> will return the film data for 'Apocalypse Now' |
| 57 | +$imdb->film("Apocalypse"); |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +### Technical Specifications |
| 62 | +A films technical specifications can also be fetched by setting the `$techSpecs` param to `true`. |
| 63 | + |
| 64 | +> Note that this will take longer as it needs to make a second request to load the tech specs. |
| 65 | +
|
| 66 | +```php |
| 67 | +// Gets film data |
| 68 | +// also gets technical specs |
| 69 | +// -> returns array of film data with `technical_specs` |
| 70 | +$imdb->film("tt0816692", $techSpecs=true); |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +## Dependencies |
| 76 | +> All dependencies are managed automatically by `composer`. |
| 77 | +
|
| 78 | +- [php-html-parser](https://github.com/paquettg/php-html-parser) |
0 commit comments