Foros del Web » Programando para Internet » PHP »

Problema con script del tiempo con API de google

Estas en el tema de Problema con script del tiempo con API de google en el foro de PHP en Foros del Web. estimados amigos tengo un script q me determina el clima de forma automatica en tiempo real, sucede perfecto mientras tenga menor a 100 usuarios online, ...
  #1 (permalink)  
Antiguo 19/12/2009, 12:28
Avatar de kernelcom-com  
Fecha de Ingreso: mayo-2008
Ubicación: Lima
Mensajes: 216
Antigüedad: 16 años
Puntos: 3
De acuerdo Problema con script del tiempo con API de google

estimados amigos tengo un script q me determina el clima de forma automatica en tiempo real, sucede perfecto mientras tenga menor a 100 usuarios online, lo demas sucede cuando tengo mas de esa cantidad. les dejo el script

Código PHP:
<?php  

ini_set
("memory_limit","1500M");
ini_set("buffering ","0");
ini_set('max_execution_time',9000);


class 
GoogleWeatherAPI {  
    private 
$city_code '';  
    private 
$city '';  
    private 
$domain 'www.google.com';  
    private 
$prefix_images '';  
    private 
$current_conditions = array();  
    private 
$forecast_conditions = array();  
    private 
$is_found true;  
  
    
/**  
    * Class constructor  
    * @param $city_code is the label of the city  
    * @param $lang the lang of the return weather labels  
    * @return ...  
    */  
       
    
function __construct ($city_code,$lang='fr') {  
        
$this->city_code $city_code;  
        
$this->prefix_images 'http://'.$this->domain;  
        
$this->url 'http://'.$this->domain.'/ig/api?weather='.urlencode($this->city_code).'&hl='.$lang;  
          
        
$content utf8_encode(file_get_contents($this->url));  
          
        
$xml simplexml_load_string($content);  
          
        if(!isset(
$xml->weather->problem_cause)) {  
              
            
$xml simplexml_load_string($content);  
  
            
$this->city = (string)$xml->weather->forecast_information->city->attributes()->data;  
  
            
$this->current_conditions['condition'] = (string)$xml->weather->current_conditions->condition->attributes()->data;  
            
$this->current_conditions['temp_f'] = (string)$xml->weather->current_conditions->temp_f->attributes()->data;  
            
$this->current_conditions['temp_c'] = (string)$xml->weather->current_conditions->temp_c->attributes()->data;  
            
$this->current_conditions['Humedad'] = (string)$xml->weather->current_conditions->humidity->attributes()->data;  
            
$this->current_conditions['icon'] = $this->prefix_images.(string)$xml->weather->current_conditions->icon->attributes()->data;  
            
$this->current_conditions['wind_condition'] = (string)$xml->weather->current_conditions->wind_condition->attributes()->data;  
              
            foreach(
$xml->weather->forecast_conditions as $this->forecast_conditions_value) {  
                
$this->forecast_conditions_temp = array();  
                
$this->forecast_conditions_temp['day_of_week'] = (string)$this->forecast_conditions_value->day_of_week->attributes()->data;  
                
$this->forecast_conditions_temp['low'] = (string)$this->forecast_conditions_value->low->attributes()->data;  
                
$this->forecast_conditions_temp['high'] = (string)$this->forecast_conditions_value->high->attributes()->data;  
                
$this->forecast_conditions_temp['icon'] = $this->prefix_images.(string)$this->forecast_conditions_value->icon->attributes()->data;  
                
$this->forecast_conditions_temp['condition'] = (string)$this->forecast_conditions_value->condition->attributes()->data;  
                
$this->forecast_conditions []= $this->forecast_conditions_temp;  
            }  
        } else {  
            
$this->is_found false;  
        }  
    }  
    function 
getCity() {  
        return 
$this->city;  
    }  
    function 
getCurrent() {  
        return 
$this->current_conditions;  
    }  
    function 
getForecast() {  
        return 
$this->forecast_conditions;  
    }  
    function 
isFound() {  
        return 
$this->is_found;  
    }  
      
}  



//llama la llama
$gweather = new GoogleWeatherAPI('lima','pe');   



if(
$gweather->isFound()) {  

foreach(
$gweather->getCurrent() as $key => $value)  

if(
$key=='temp_c'){ $temperatura=' '.$value.'°C';  echo $temperatura; } else { echo ' '; }
//fin del poreach

}// end if


?>
Ello imprime ejemplo: 25ºC

Pero sucede este error:

Código:
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : Opening and ending tag mismatch: meta line 1 and HEAD in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: <TITLE>302 Moved</TITLE></HEAD><BODY> in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/dprimera/public_html/online/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 6: parser error : Opening and ending tag mismatch: HEAD line 1 and HTML in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: </BODY></HTML> in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/dprimera/public_html/online/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser error : Premature end of data in tag HTML line 1 in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/***user***/public_html/temperatura.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : Opening and ending tag mismatch: meta line 1 and HEAD in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: <TITLE>302 Moved</TITLE></HEAD><BODY> in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 6: parser error : Opening and ending tag mismatch: HEAD line 1 and HTML in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: </BODY></HTML> in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser error : Premature end of data in tag HTML line 1 in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: in /home/***user***/public_html/temperatura.php on line 35

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/***user***/public_html/temperatura.php on line 35

Fatal error: Call to a member function attributes() on a non-object in /home/***user***/public_html/temperatura.php on line 37
espero sus ayudas amigos ya que este script es muy bueno para diferentes cosas, gracia spor su aporte.
__________________
Las ideas estimulan la mente.(Eric Hoffer)
http://www.reycarlos.com
http://www.clasificadosde.com
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:19.