Page 1 of 1

IMDB API

Posted: Wed Jun 27, 2012 7:38 pm
by wrichards8
For reasons best known to them. the IMDB do not have their own official API (I don't think) so we have to use ones imdbapi.com. I have just figured out how to get this working, so will probably be implementing this in my site. You will need the name of the film, the year may also help.

Fetch the object from the website and put it into a variable
$get_imdb_api = file_get_contents("http://www.imdbapi.com/?t=something");
It is JSON, so decode it
$get_imdb_api = json_decode($get_imdb_api); 
We want to put it in an array because, currently, its an object
$get_imdb_api = get_object_vars($get_imdb_api);
If you need the year, add y=theyear

Hope this hopes and, like I said, I will be implementing this on my site

Re: IMDB API

Posted: Wed Jun 27, 2012 7:58 pm
by jacek
Useful !

You can also make json_decode() return an array by doing
$get_imdb_api = json_decode($get_imdb_api, true);
:D