Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/05/2012, 08:30
milo9_9
 
Fecha de Ingreso: noviembre-2011
Ubicación: Bogotá
Mensajes: 7
Antigüedad: 12 años, 5 meses
Puntos: 0
Exclamación Error con file_get_contents

El error es el siguiente:

estoy creando un sistema de clima para php el cual se conecta a la api de google del clima en el hosting de webcindario me funciona normal pero al momento de probarlo en local me ocurre este error


Warning: file_get_contents(http://www.google.com/ig/api?weather=bogota&hl=es) [function.file-get-contents]: failed to open stream: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder. in C:\xampp\htdocs\clima_final\datos.php on line 16

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\clima_final\datos.php on line 16

lo mismo ocurre cuando intento ingresarlo en el hosting de producción la verdad no se como solucionar esto

este es el codigo que estoy utilizando

Código PHP:
require 'xml2array.php';

$dep $_POST['dep'];
$url "http://www.google.com/ig/api?weather=" $dep "&hl=es";

$url_tr str_replace(" ""%20"$url);
$contents utf8_encode(file_get_contents($url_tr));
$data xml2array($contents);

$weather_info $data['xml_api_reply']['weather']['forecast_information'];
$weather_current $data['xml_api_reply']['weather']['current_conditions'];
$weather_forecast $data['xml_api_reply']['weather']['forecast_conditions'];