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
[syntax=php]$get_imdb_api = file_get_contents("http://www.imdbapi.com/?t=something");[/syntax]
It is JSON, so decode it
[syntax=php]$get_imdb_api = json_decode($get_imdb_api); [/syntax]
We want to put it in an array because, currently, its an object
[syntax=php]
$get_imdb_api = get_object_vars($get_imdb_api);[/syntax]
If you need the year, add y=theyear
Hope this hopes and, like I said, I will be implementing this on my site
IMDB API
-
- Posts: 66
- Joined: Thu Jan 12, 2012 3:54 pm
- Contact:
Re: IMDB API
Useful !
You can also make json_decode() return an array by doing
[syntax=php]$get_imdb_api = json_decode($get_imdb_api, true);[/syntax]
You can also make json_decode() return an array by doing
[syntax=php]$get_imdb_api = json_decode($get_imdb_api, true);[/syntax]