Created
December 22, 2011 21:56
-
-
Save rev087/1512028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prepare the API call | |
$search_string = urlencode("City of God"); | |
$API_KEY = "<redacted>"; | |
$URL = "http://api.themoviedb.org/2.1/Movie.search/en/xml/{$API_KEY}/{$search_string}"; | |
// Perform the API call | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $URL); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
// Parse the XML response | |
$doc = new DOMDocument(); | |
@$doc->loadHTML($output); | |
// Traverse the DOM node tree | |
$movies = $doc->getElementsByTagName("movie"); | |
for ($i=0; $i<$movies->length; $i++) { | |
$movie = $movies->item($i); | |
$overview = $movie->getElementsByTagName("overview")->item(0); | |
var_dump($overview->textContent); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
string(248) "City of God is one of the most successful Brazilian films of all times. It depicts the raw violence in the ghettos of Rio de Janeiro in the 1970’s that even had young kids carrying guns and joining gangs when they should be playing hide-and-seek."