Hi Leute,
ich hab hier ein kleines Problem:
Ich möchte mit diesem PHP Skript von Google Wetter API selbstverständlich die Wetteradten abrufen. Aber dafür möchte ich die Icons nutzen, die ich extra erstellt habe, und nicht die vom Google Server!
Hab die Daten gleich genannt, wie die GIFs von Goolgle. Nur brauch ich Hilfe bei der Bennenung des Pfades usw.!
Hier das PHP Skript:
<!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>Unbenanntes Dokument</title>
<style type="text/css">
<!--
#aktuell_wetter {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: normal;
background-color: #09F;
text-align: center;
}
-->
</style>
</head>
<body>
<?php
// Funktionsaufruf z.B.: $wetter = website_wetter("46562", "Germany", "/images/wetter/icons/", "de");
function website_wetter($plz, $land, $icons_src="/", $sprache="de", $ort="")
{
$icons_google = "/ig/images/weather/";
if($ort != "")
{
$station = $ort;
}
else
{
$station = $plz."-".$land;
}
$api = simplexml_load_string(utf8_encode(file_get_contents("http://www.google.com/ig/api?weather=".$station."&hl=".$sprache)));
$wetter = array();
// Allgemeine Informationen
$wetter['stadt'] = $api->weather->forecast_information->city->attributes()->data;
$wetter['datum'] = $api->weather->forecast_information->forecast_date->attributes()->data;
$wetter['zeit'] = $api->weather->forecast_information->current_date_time->attributes()->data;
// 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($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($icons_google, $icons_src, $weather->icon->attributes()->data);
$i++;
}
return $wetter;
}
// Funktionsaufruf in Array
$wetter = website_wetter("91522", "Germany");
// Beispielhafte Ausgabe
echo "<h1>".$wetter['stadt'].":</h1>\n";
echo "<div id=aktuell_wetter>";
echo "<strong>Aktuell:</strong><br/>\n";
echo $wetter[0]['zustand']."<br/>\n";
echo "Temperatur: ".$wetter[0]['temperatur']."° C<br/>\n";
echo $wetter[0]['luftfeuchtigkeit']."<br/>\n";
echo $wetter[0]['wind']."<br/>\n";
echo "<img src=\"http://www.google.com/ig/images/weather".$wetter[0]['icon']."\" alt=\"".$wetter[0]['zustand']."\" />\n";
echo "<p>";
echo "<strong>".$wetter[1]['wochentag']."</strong><br/>\n";
echo $wetter[1]['zustand']."<br/>\n";
echo "min. ".$wetter[1]['tiefsttemperatur']."° C | max. ".$wetter[1]['hoechsttemperatur']."° C<br/>\n";
echo "<img src=\"http://www.google.com/ig/images/weather".$wetter[1]['icon']."\" alt=\"".$wetter[1]['zustand']."\" />\n";
echo "</p>";
echo "<p>";
echo "<strong>".$wetter[2]['wochentag']."</strong><br/>\n";
echo $wetter[2]['zustand']."<br/>\n";
echo "min. ".$wetter[2]['tiefsttemperatur']."° C | max. ".$wetter[2]['hoechsttemperatur']."° C<br/>\n";
echo "<img src=\"http://www.google.com/ig/images/weather".$wetter[2]['icon']."\" alt=\"".$wetter[2]['zustand']."\" />\n";
echo "</p>";
echo "<p>";
echo "<strong>".$wetter[3]['wochentag']."</strong><br/>\n";
echo $wetter[3]['zustand']."<br/>\n";
echo "min. ".$wetter[3]['tiefsttemperatur']."° C | max. ".$wetter[3]['hoechsttemperatur']."° C<br/>\n";
echo "<img src=\"http://www.google.com/ig/images/weather".$wetter[3]['icon']."\" alt=\"".$wetter[3]['zustand']."\" />\n";
echo "</p>";
echo "<p>";
echo "<strong>".$wetter[4]['wochentag']."</strong><br/>\n";
echo $wetter[4]['zustand']."<br/>\n";
echo "min. ".$wetter[4]['tiefsttemperatur']."° C | max. ".$wetter[4]['hoechsttemperatur']."° C<br/>\n";
echo "<img src=\"http://www.google.com/ig/images/weather".$wetter[4]['icon']."\" alt=\"".$wetter[4]['zustand']."\" />\n";
echo "</p>";
echo "</div>";
?>
</body>
</html>