Ver Mensaje Individual
  #15 (permalink)  
Antiguo 29/09/2011, 18:06
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: file_get_contents falla

Haciendo esta prueba demora siglos en devolver el XML (hasta 15 minutos) y aveces se demora 3 segundos...

Código PHP:
Ver original
  1. <?php
  2.  
  3. $context = stream_context_create(array('http' => array('timeout' => 889))); //timeout
  4.  
  5. $xml_get = file_get_contents(
  6. "http://xml.e-travelsolution.com/xml/enginexml-agencies.asmx/getQuoteHotels?a=k4r3n-4n3l&pwd=5ecr370&c=PE&sd=20111111&ed=20111116&h=&rt=&mp=&r=1&r1a=2&r1k=0&r1k1a=-1&r1k2a=-1&r1k3a=-1&r2a=-1&r2k=-1&r2k1a=-1&r2k2a=-1&r2k3a=-1&r3a=-1&r3k=-1&r3k1a=-1&r3k2a=-1&r3k3a=-1&r4a=-1&r4k=-1&r4k1a=-1&r4k2a=-1&r4k3a=-1&r5a=-1&r5k=-1&r5k1a=-1&r5k2a=-1&r5k3a=-1&d=2&l=ESP&categoryid=&locationid=&chainid=&cityid=&fq=&co=MX",
  7. 0, $context);
  8.  
  9. $xml = new SimpleXMLElement($xml_get);
  10.  
  11. foreach ($xml->hotels->hotel as $item) {
  12.     $hoteles[] = array("idhotel" => (int) $item->hotelid,
  13.     "hotelname" => (string) ($item->hotelname), "ciudad" => (string) $item->cityname,
  14.     "ubicacionid" => (string) $item->ubicationid, "categoria" => (string) $item->categoryid,
  15.     "tarifaneta" => (int) $item->rooms->Roomrates->rate);
  16. }
  17.  
  18. echo '<pre>';
  19. print_r($hoteles);
  20. echo '</pre>';
  21.  
  22. if ($xml_get) {
  23.  
  24. } else {
  25.     echo "No disponible";
  26. }
  27. ?>

Yo colocaría el límite de tiempo como te dije en mi post # 7, cuando se demore mucho colocar un mensaje y ya. Seguiré investigando, cualquier cosa te aviso.

Saludos.
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP