Wednesday, 21 August 2013

How to return the rotten tomatoes API Json response to PHP readable

How to return the rotten tomatoes API Json response to PHP readable

so I'm learning programming and beginning to start using my first API.
Just something simple, like using the rotten tomatoes API to get
information for movies.
Anyway, I use the API to search for movies that contain "face" and it
gives me a json response. Putting the variable I saved it to through
var_export and printing to screen the assosiative array looks like
array ( 'total' => 378, 'movies' => array ( 0 => array ( 'id' =>
'771324575', 'title' => 'Jug Face', 'year' => 2013, 'mpaa_rating' => 'R',
'runtime' => 81, 'release_dates' => array ( 'theater' => '2013-08-09', ),
'ratings' => array ( 'critics_rating' => 'Fresh', 'critics_score' => 82,
'audience_rating' => 'Spilled', 'audience_score' => 39, ), 'synopsis' =>
'JUG FACE tells the story of a pregnant teen trying to escape a backwoods
community when she discovers that she may be sacrificed to a mysterious
pit. The entity in the pit requires a life for keeping the community safe.
The face of the person to be sacrificed is crafted onto a ceramic jug.
When ignored, the entity unleashes an evil onto the community. Now no one
is safe as tragedy befalls each member one by one and they soon realize
that the pit wants what it wants. (c) Modern Distributors', 'posters' =>
array ( 'thumbnail' => 'xxxx', 'profile' => 'xxxx', 'detailed' => 'xxxx',
'original' => 'xxxx', ), 'abridged_cast' => array ( 0 => array ( 'name' =>
'Lauren Ashley Carter', 'id' => '770910792', 'characters' => array ( 0 =>
'Ada', ), ), 1 => array ( 'name' => 'Sean Bridgers', 'id' => '770749896',
'characters' => array ( 0 => 'Dawai', ), ), 2 => array ( 'name' => 'Larry
Fessenden', 'id' => '162727376', 'characters' => array ( 0 => 'Sustin', ),
), 3 => array ( 'name' => 'Sean Young', 'id' => '162671441', 'characters'
=> array ( 0 => 'Loris', ), ), 4 => array ( 'name' => 'Daniel Manche',
'id' => '770679306', 'characters' => array ( 0 => 'Jessaby', ), ), ),
'alternate_ids' => array ( 'imdb' => '2620736', ), 'links' => array (
'self' =>
And it continues on...
Can somebody please tell me how I can echo the title, year, and synopsis
of each movie in this array?
I have tried all manner of variations of "foreach" loops but I can't for
the life of me figure out the correct syntax.
Thanks in advance.

No comments:

Post a Comment