Este es un ejemplo del xml que quiero leer (http://api.themoviedb.org/2.1/Movie.getImages/en/xml/APIKEY/27205 ):
Código:
Y esto es el php que estoy usando para leerlo :<OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"> <opensearch:Query searchTerms="27205"/> <opensearch:totalResults>1</opensearch:totalResults> <movies> <movie> <id>27205</id> <name>Inception</name> <images> <poster id="4ea65cbe34f8633bdc008035"> <image url="http://cf2.imgobject.com/t/p/w92/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="thumb" width="92" height="138"/> <image url="http://cf2.imgobject.com/t/p/w154/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="w154" width="154" height="231"/> <image url="http://cf2.imgobject.com/t/p/w185/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="cover" width="185" height="278"/> <image url="http://cf2.imgobject.com/t/p/w342/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="w342" width="342" height="513"/> <image url="http://cf2.imgobject.com/t/p/w500/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="mid" width="500" height="750"/> <image url="http://cf2.imgobject.com/t/p/original/ziKvu3Th9l1wN2aIeVj5ElpBqFu.jpg" size="original" width="1000" height="1500"/> </poster> <poster id="4ea65cbc34f8633bdc008033"> <image url="http://cf2.imgobject.com/t/p/w92/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="thumb" width="92" height="138"/> <image url="http://cf2.imgobject.com/t/p/w154/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="w154" width="154" height="231"/> <image url="http://cf2.imgobject.com/t/p/w185/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="cover" width="185" height="278"/> <image url="http://cf2.imgobject.com/t/p/w342/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="w342" width="342" height="513"/> <image url="http://cf2.imgobject.com/t/p/w500/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="mid" width="500" height="750"/> <image url="http://cf2.imgobject.com/t/p/original/e8MyVAjISnQ8TCcOPQ0Pk2PTe46.jpg" size="original" width="1000" height="1500"/> </poster> <backdrop id="4ea65c2634f8633bdc007fbd"> <image url="http://cf2.imgobject.com/t/p/w300/cAJOtfT8LvFRMWUXf9dlnpQ2TWf.jpg" size="thumb" width="300" height="188"/> <image url="http://cf2.imgobject.com/t/p/w780/cAJOtfT8LvFRMWUXf9dlnpQ2TWf.jpg" size="poster" width="780" height="488"/> <image url="http://cf2.imgobject.com/t/p/w1280/cAJOtfT8LvFRMWUXf9dlnpQ2TWf.jpg" size="w1280" width="1280" height="800"/> <image url="http://cf2.imgobject.com/t/p/original/cAJOtfT8LvFRMWUXf9dlnpQ2TWf.jpg" size="original" width="1920" height="1200"/> </backdrop> </images> </movie> </movies> </OpenSearchDescription>
Código PHP:
<?php
$api_title="http://api.themoviedb.org/2.1/Movie.search/es/xml/APIKEY/".$_GET['titulo'];
$data_title = new SimpleXMLElement($api_title, null, true);
foreach($data_title->movies->movie as $movie){
$id= $movie->id;
//Primero consigue el Id de la película que estas buscando.
echo $id;
echo "<br>";
$api_image="http://api.themoviedb.org/2.1/Movie.getImages/es/xml/APIKEY/".$id;
//Este es el XML que pongo como ejemplo arriba.
//Con ese id se conecta para obtener las imágenes.
$data_image = new SimpleXMLElement($api_image, null, true);
foreach($data_image->movies->movie->images->poster as $poster){
foreach($poster->image as $image){
foreach($image->attributes as $attri){
$url = $attri->url;
echo $url;
echo "<br>";
}
}
}
echo "<br>";
}
?>
Como puedo hacerlo? MIL GRACIAS