IMDB API

Any tutorials (or useful resources) should go in here.
Post Reply
wrichards8
Posts: 66
Joined: Thu Jan 12, 2012 3:54 pm
Contact:

IMDB API

Post 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
Last edited by jacek on Wed Jun 27, 2012 7:58 pm, edited 1 time in total.
Reason: Corrected title.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: IMDB API

Post by jacek »

Useful !

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