Check weather data
This commit is contained in:
17
inc/Feed.php
17
inc/Feed.php
@@ -232,13 +232,24 @@ class Feed extends PhpObject {
|
||||
$sApiUrl = self::WEATHER_HOOK.'/'.$asLatLng[0].','.$asLatLng[1].'/'.$iTimeStamp.'?'.http_build_query(self::WEATHER_PARAM);
|
||||
$asWeather = json_decode(file_get_contents($sApiUrl), true);
|
||||
|
||||
if(array_key_exists('currentConditions', $asWeather)) { //Current conditions
|
||||
$sWeatherIcon = $asWeather['currentConditions']['icon'];
|
||||
$sWeatherCond = $asWeather['currentConditions']['conditions'];
|
||||
$sWeatherTemp = $asWeather['currentConditions']['temp'];
|
||||
}
|
||||
else { //Daily Conditions
|
||||
$sWeatherIcon = $asWeather['days'][0]['icon'];
|
||||
$sWeatherCond = $asWeather['days'][0]['conditions'];
|
||||
$sWeatherTemp = $asWeather['days'][0]['temp'];
|
||||
}
|
||||
|
||||
//Get Condition ID
|
||||
$sCondKey = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($asWeather['currentConditions']['conditions']);
|
||||
$sCondKey = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($sWeatherCond);
|
||||
|
||||
return array(
|
||||
'weather_icon' => $asWeather['currentConditions']['icon'],
|
||||
'weather_icon' => $sWeatherIcon,
|
||||
'weather_cond' => $sCondKey,
|
||||
'weather_temp' => floatval($asWeather['currentConditions']['temp'])
|
||||
'weather_temp' => floatval($sWeatherTemp)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user