It seems you need to do an additional request to /3/configuration
in order to get some extra info.
The parameter you are looking for is base_url
which you can use to construct the urls.
Read more here: http://docs.themoviedb.apiary.io/#get-%2F3%2Fconfiguration
You may be wondering why is that required. According to their site, they did it so they can keep their API light, and it seems the base_url
rarely changes (see https://www.themoviedb.org/talk/515a72d0760ee3615a0b5256 for more)
So, you could do that request only once every X time (like once a day for instance) and then use the base_url
I get there in all the subsequent requests I may need to do.
EDIT: Sigh, I thought you had problems only for not having the base_url
, not with getting the data from the json.
Anyway, just replace the last line to this:
echo("<img src='" . $config['images']['base_url'] . $config['images']['poster_sizes'][2] . $result['results'][0]['poster_path'] . "'/>");
And that's it.