habe mal eine Wetterbox zusammengeschnipselt sie funktioniert auch allerdings mit ein paar mängel. Wer kann weiterhelfen damit wir es hier auf Ilch veröffentlich können?
Problem 1: Die Box zeigt leider nur mein Wetter an möchte aber das wenn ein User auf die HP kommt seine Postleitzahl eingibt oder per IP erkannt wird wo er herkommt und automatisch sein Wetter angezeigt wird.
Problem 2: Die Umlaute werden nicht richtig dargestellt. Gebe ich im Script
1 | header('content-type: text/html; charset=utf8'); |
Script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | <?php defined ('main') or die ( 'keinen Direkten Zugang' ); 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("86356", "de"); // Beispielhafte Ausgabe echo "<h5>".$wetter['stadt'].":</h5>"; echo '<hr>'; echo "<table border=0 style=background-color:transparent width=208 cellpadding=3 cellspacing=0> <tr> <td rowspan=4><img src=\"http://google.com/ig/images/weather".$wetter[0]['icon']."\" alt=\"".$wetter[0]['zustand']."\" /></td> <td><strong>Aktuell: </strong>".$wetter[0]['zustand']."</td> </tr> <tr> <td>Temperatur: ".$wetter[0]['temperatur']."° C</td> </tr> <tr> <td>".$wetter[0]['luftfeuchtigkeit']."</td> </tr> <tr> <td>".$wetter[0]['wind']."</td> </tr> </table>"; echo '<hr>'; echo "<table border=0 style=background-color:transparent width=208 cellpadding=3 cellspacing=0> <tr> <td rowspan=3><img src=\"http://google.com/ig/images/weather".$wetter[1]['icon']."\" alt=\"".$wetter[1]['zustand']."\" /></td> <td><strong>".$wetter[1]['wochentag']."</strong></td> </tr> <tr> <td>".$wetter[1]['zustand']."</td> </tr> <tr> <td>min. ".$wetter[1]['tiefsttemperatur']."° C | max. ".$wetter[1]['hoechsttemperatur']."° C</td> </tr> </table>"; echo '<hr>'; echo "<table border=0 style=background-color:transparent width=208 cellpadding=3 cellspacing=0> <tr> <td rowspan=3><img src=\"http://google.com/ig/images/weather".$wetter[2]['icon']."\" alt=\"".$wetter[2]['zustand']."\" /></td> <td><strong>".$wetter[2]['wochentag']."</strong></td> </tr> <tr> <td>".$wetter[2]['zustand']."</td> </tr> <tr> <td>min. ".$wetter[2]['tiefsttemperatur']."° C | max. ".$wetter[2]['hoechsttemperatur']."° C</td> </tr> </table>"; echo '<hr>'; echo "<table border=0 style=background-color:transparent width=208 cellpadding=3 cellspacing=0> <tr> <td rowspan=3><img src=\"http://google.com/ig/images/weather".$wetter[3]['icon']."\" alt=\"".$wetter[3]['zustand']."\" /></td> <td><strong>".$wetter[3]['wochentag']."</strong></td> </tr> <tr> <td>".$wetter[2]['zustand']."</td> </tr> <tr> <td>min. ".$wetter[3]['tiefsttemperatur']."° C | max. ".$wetter[3]['hoechsttemperatur']."° C</td> </tr> </table>"; echo '<hr>'; echo "<table border=0 style=background-color:transparent width=208 cellpadding=3 cellspacing=0> <tr> <td rowspan=3><img src=\"http://google.com/ig/images/weather".$wetter[4]['icon']."\" alt=\"".$wetter[4]['zustand']."\" /></td> <td><strong>".$wetter[4]['wochentag']."</strong></td> </tr> <tr> <td>".$wetter[4]['zustand']."</td> </tr> <tr> <td>min. ".$wetter[4]['tiefsttemperatur']."° C | max. ".$wetter[4]['hoechsttemperatur']."° C</td> </tr> </table>"; echo '<hr>'; |
betroffene Homepage: homepageleichtgemacht.com