http://www.omdbapi.com/?t=$title&y=$yearThe API url has many parameters that can be passed to get corresponding result about a movie.
The parameters are mentioned below.
Code to get the movie information
<?php //Get the title of the movie $title = "Doom 3"; //'y'(Year) key at the end of the url is optional. //But its always good practice to sent the year; //as title can be same for multiple movies $year = ""; //Replace spaces and apostrophe mark in the title with html entities //This will make title from 'Doom 3' //to //'Doom%203' $title = urlencode($title); //Call the omdb api $json=file_get_contents("http://www.omdbapi.com/?t=$title&y=$year"); $details=json_decode($json); //Check if respose contains the movie information if($details->Response=='True') { echo "<b>IMDB-ID </b> : ".$details->imdbID.'<br>'; echo "<b>Title </b>: ".$details->Title.'<br>'; echo "<b>Year </b>: ".$details->Year.'<br>'; echo "<b>Rated </b>: ".$details->Rated.'<br>'; echo "<b>Poster Image Path</b>: ".$details->Poster.'<br>'; echo "<img src=\"$details->Poster\"><br>"; echo "<b>Released Date</b>: ".$details->Released.'<br>'; echo "<b>Runtime </b>: ".$details->Runtime.'<br>'; echo "<b>Genre </b>: ".$details->Genre.'<br>'; echo "<b>Director </b>: ".$details->Director.'<br>'; echo "<b>Writer </b>: ".$details->Writer.'<br>'; echo "<b>Actors </b>: ".$details->Actors.'<br>'; echo "<b>Plot </b>: ".$details->Plot.'<br>'; echo "<b>Language </b>: ".$details->Language.'<br>'; echo "<b>Country </b>: ".$details->Country.'<br>'; echo "<b>Awards </b>: ".$details->Awards.'<br>'; echo "<b>Metascore </b>: ".$details->Metascore.'<br>'; echo "<b>IMDB Rating </b> : ".$details->imdbRating.'<br>'; echo "<b>IMDB Votes </b>: ".$details->imdbVotes.'<br>'; } //Show message if the movie information is not returned by APIs else { echo "Movie information not available.Please confirm title"; } ?>
No comments:
Post a Comment