From aa6fb62cf8691eb84bae3ee580f4272424f472a5 Mon Sep 17 00:00:00 2001 From: martinhaas Date: Thu, 25 Feb 2010 09:35:49 +0000 Subject: [PATCH] errorhandling for google-weather git-svn-id: https://svn.fhem.de/fhem/trunk@576 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/webfrontend/pgm3/include/weather.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fhem/webfrontend/pgm3/include/weather.php b/fhem/webfrontend/pgm3/include/weather.php index 3a8a5e354..79539dc28 100644 --- a/fhem/webfrontend/pgm3/include/weather.php +++ b/fhem/webfrontend/pgm3/include/weather.php @@ -13,14 +13,16 @@ function website_WEATHER($station, $land, $sprache) $icons_google = "/ig/images/weather/"; $api = simplexml_load_string(utf8_encode(file_get_contents("http://www.google.com/ig/api?weather=".$station."&hl=".$sprache))); - if (!$api) {$WEATHER="FALSE"; return $WEATHER;}; + if (! $api->weather->forecast_information) { $WEATHER="FALSE"; return $WEATHER;}; #print_r($api); #exit; $WEATHER = array(); - + $WEATHER['city'] = $api->weather->forecast_information->city->attributes()->data; + $WEATHER['datum'] = $api->weather->forecast_information->forecast_date->attributes()->data; + $WEATHER['zeit'] = $api->weather->forecast_information->current_date_time->attributes()->data; $WEATHER[0]['condition'] = $api->weather->current_conditions->condition->attributes()->data; @@ -48,7 +50,7 @@ function website_WEATHER($station, $land, $sprache) $WEATHER = website_WEATHER($weathercity, $weathercountry, $weatherlang); if ($WEATHER=="FALSE") { - echo "Google-Weather-Api is not reachable."; + echo "Google-Weather-Api failed."; } else {