Wettervorhersage

Hallo zusammen,

gestern hab ich die Threads zu dem Auslesen der Wetterdaten von Google gelesen. Ich hab mir den Code ein wenig abgeändert, um nur die reine Vorhersage zu haben. Das ganze wird dann in einer HTML-Box dargestellt.
Vielleicht kann es ja jemand brauchen. :slight_smile:
Ach ja, die Icons liegen bei mir lokal unter …/webfront/user/weather.

Hier das Skript:


<?
// Wettervorhersage abrufen
$plz         =    "88718";
$land        =    "Germany";
$icons_src   =    "/user/";
$sprache     =    "de";
$ort         =    "Daisendorf";
$icons_google = "/ig/images/";
if($ort != "") {
	$station = $ort;
} else {
	$station = $plz."-".$land;
}
$api = simplexml_load_string(utf8_encode(@Sys_GetURLContent("http://www.google.com/ig/api?weather=".$station."&hl=".$sprache)));
$wetter = array();
// Aktuelles Wetter
$wetter[0]['zustand'] = $api->weather->current_conditions->condition->attributes()->data;
$wetter[0]['temperatur'] = $api->weather->current_conditions->temp_c->attributes()->data;
$wetter[0]['luftfeuchtigkeit'] = $api->weather->current_conditions->humidity->attributes()->data;
$wetter[0]['wind'] = $api->weather->current_conditions->wind_condition->attributes()->data;
$wetter[0]['icon'] = str_replace("gif", "png", str_replace($icons_google, $icons_src, $api->weather->current_conditions->icon->attributes()->data));
// Wettervorhersage heute, morgen, in zwei und in drei Tagen ($wetter[1] bis $wetter[4])
$i = 1;
foreach($api->weather->forecast_conditions as $weather) {
	$wetter[$i]['wochentag'] = $weather->day_of_week->attributes()->data;
	$wetter[$i]['zustand'] = $weather->condition->attributes()->data;
	$wetter[$i]['tiefsttemperatur'] = $weather->low->attributes()->data;
	$wetter[$i]['hoechsttemperatur'] = $weather->high->attributes()->data;
	$wetter[$i]['icon'] = str_replace("gif", "png", str_replace($icons_google, $icons_src, $weather->icon->attributes()->data));
	$i++;
}
$bordercolor = "#3b3b4d";
// Tag Morgen
$str = "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/ArrowRight.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".wochentag($wetter[2]['wochentag'])."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Tag</td>".$value."</tr>";
$str .= "</table>";
// Prognose Morgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Image.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b><img src=".$wetter[2]['icon']."></td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Prognose</td>".$value."</tr>";
$str .= "</table>";
// Zustand Morgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Information.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[2]['zustand']."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Zustand</td>".$value."</tr>";
$str .= "</table>";
// Temperatur Morgen
$str .= "<table style='border-bottom:1px solid $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Temperature.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[2]['tiefsttemperatur']." / ".$wetter[2]['hoechsttemperatur']." °C</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Temperatur Min/Max</td>".$value."</tr>";
$str .= "</table>";
$str .= "<table><tr height='5px'><td></td></tr></table>";
// Tag Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/ArrowRight.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".wochentag($wetter[3]['wochentag'])."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Tag</td>".$value."</tr>";
$str .= "</table>";
// Prognose Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Image.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b><img src=".$wetter[3]['icon']."></td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Prognose</td>".$value."</tr>";
$str .= "</table>";
// Zustand Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Information.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[3]['zustand']."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Zustand</td>".$value."</tr>";
$str .= "</table>";
// Temperatur Übermorgen
$str .= "<table style='border-bottom:1px solid $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Temperature.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[3]['tiefsttemperatur']." / ".$wetter[3]['hoechsttemperatur']." °C</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Temperatur Min/Max</td>".$value."</tr>";
$str .= "</table>";
$str .= "<table><tr height='5px'><td></td></tr></table>";
// Tag Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/ArrowRight.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".wochentag($wetter[4]['wochentag'])."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Tag</td>".$value."</tr>";
$str .= "</table>";
// Prognose Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Image.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b><img src=".$wetter[4]['icon']."></td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Prognose</td>".$value."</tr>";
$str .= "</table>";
// Zustand Übermorgen
$str .= "<table style='border-bottom:1px $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Information.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[4]['zustand']."</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Zustand</td>".$value."</tr>";
$str .= "</table>";
// Temperatur Übermorgen
$str .= "<table style='border-bottom:1px solid $bordercolor' width='100%' cellspacing='0'>";
$img = "<td style='border-width:1px 0 0 1px; border-style:solid; border-color:$bordercolor;' align='center' bgcolor='#27292b' width='38px'><img src=/img/icons/Temperature.png></td>";
$value = "<td style='border-width:1px 1px 0 1px; border-style:solid; border-color:$bordercolor;' width='49%' align='center' bgcolor=#27292b>".$wetter[4]['tiefsttemperatur']." / ".$wetter[4]['hoechsttemperatur']." °C</td>";
$str .= "<tr height='41px'>$img<td style='border-top:1px solid $bordercolor' bgcolor='#27292b' width='38%'>Temperatur Min/Max</td>".$value."</tr>";
$str .= "</table>";
//print_r($str);
SetValue(46116 /*[Übersicht\Wetter\Vorhersage\Wettervorhersage]*/, $str);

function wochentag($day) {
	switch ($day) {
	   case "So.":
	      return "Sonntag";
	      break;
	   case "Mo.":
	      return "Montag";
	      break;
	   case "Di.":
	      return "Dienstag";
	      break;
	   case "Mi.":
	      return "Mittwoch";
	      break;
	   case "Do.":
	      return "Donnerstag";
	      break;
	   case "Fr.":
	      return "Freitag";
	      break;
	   case "Sa.":
	      return "Samstag";
	      break;
	}
}
?>

Im Anhang, wie´s dann ausschaut. Nichts besonderes, aber mir reicht das als Info.

Gruß
dfhome