Vorrei inserire sul sito le previsioni meteo di google ma senza pubblicità. Perché secondo voi questo script non funziona?
http://www.ubaldogulotta.eu/Senzatitolo-1.php
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
<?php
function get_weather($destination)
{
$ch = curl_init();
$result = ”;
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/ig/api?weather='.$destination.'&hl=it');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RITORNA IL CONTENUTO DELLA CHIAMATA
$res = utf8_encode(curl_exec($ch));
if ($res === false)
{
echo 'Impossibile ottenere meteo.';
return false;
}
$xml = new SimplexmlElement($res);
if (! empty($xml->weather->current_conditions))
{
foreach($xml->weather as $item) {
foreach($item->forecast_conditions as $new) {
$result .= ' <div class="weather_icon" >'.ucfirst($new->day_of_week['data']).' <br / >
<img src="http://www.google.com/' .$new->icon['data'] . '"/> <br / >'.
$new->low['data'].'-'.$new->high['data'].'°C</div >';
}
}
}
return $result;
}
echo get_weather("95013");
?>
</body>
</html>![]()
![]()
![]()
In questa pagina fatta in joomla da un mio amico potete vedere l'esempio:
http://www.puzzole.com/agriturismo-a...cola-fattoria/
ciao e grazie