1. Go to this page and download the library: Download zero-to-prod/omdb-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zero-to-prod / omdb-api example snippets
use Zerotoprod\OmdbApi\OmdbApi;
$OmdbApi = new OmdbApi('apiKey');
// Find a title by ImdbID (Internet Movie DataBase ID) or title
$OmdbApi->byIdOrTitle('Avatar')['Title']; // 2009
// Find multiple titles
$OmdbApi->search('Avatar')['Search'][0]['Year']; // 2009
// Get the poster art of a title by its ImdbID
$OmdbApi->poster('tt0499549'); // https://img.omdbapi.com/?apikey=8f8423aa&i=tt0499549
use Zerotoprod\OmdbApi\OmdbApi;
$OmdbApi = new OmdbApi('apiKey');
public function byIdOrTitle(
?string $title = null, // (optional): A string containing the title to look up (e.g. “Avatar”)
?string $imdbID = null, // (optional): A valid IMDb ID (e.g. “tt1285016”)
?string $type = null, // (optional): The type of media to search for. Acceptable values are “movie”, “series”, "game", or “episode”.
?int $year = null, // (optional): Year of release
?bool $full_plot = false, // (optional): If true, returns the full plot instead of a short summary
mixed $callback = null, // (optional): JSONP callback name (if needed).
?string $version = null, // (optional): Reserved for future use.
?array $CURLOPT = [CURLOPT_TIMEOUT => 10] // An associative array of [cURL options](https://www.php.net/manual/en/function.curl-setopt.php). Defaults to [CURLOPT_TIMEOUT => 10].
): array
[
"Title" => "Avatar",
"Year" => "2009",
"Rated" => "PG-13",
"Released" => "18 Dec 2009",
"Runtime" => "162 min",
"Genre" => "Action, Adventure, Fantasy",
"Director" => "James Cameron",
"Writer" => "James Cameron",
"Actors" => "Sam Worthington, Zoe Saldana, Sigourney Weaver",
"Plot" => "A paraplegic Marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language" => "English, Spanish",
"Country" => "United States, United Kingdom",
"Awards" => "Won 3 Oscars. 91 wins & 131 nominations total",
"Poster" => "https://m.media-amazon.com/images/M/MV5BMDEzMmQwZjctZWU2My00MWNlLWE0NjItMDJlYTRlNGJiZjcyXkEyXkFqcGc@._V1_SX300.jpg",
"Ratings" => [
[
"Source" => "Internet Movie Database",
"Value" => "7.9/10"
],
[
"Source" => "Rotten Tomatoes",
"Value" => "81%"
],
[
"Source" => "Metacritic",
"Value" => "83/100"
]
],
"Metascore" => "83",
"imdbRating" => "7.9",
"imdbVotes" => "1,411,534",
"imdbID" => "tt0499549",
"Type" => "movie",
"DVD" => "N/A",
"BoxOffice" => "$785,221,649",
"Production" => "N/A",
"Website" => "N/A",
"Response" => "True"
];
public function search(
string $title, // ( “series”, or “episode”
?int $year = null, // Year of release to narrow down results
?int $page = 1, // (optional): Page number for paginated results
mixed $callback = null, // (optional): JSONP callback name
?string $version = null,// (optional): Reserved for future use
?array $CURLOPT = [CURLOPT_TIMEOUT => 10] // An associative array of [cURL options](https://www.php.net/manual/en/function.curl-setopt.php). Defaults to [CURLOPT_TIMEOUT => 10].
): array