diff --git a/lib/Weather_OWM.lib.php b/lib/Weather_OWM.lib.php new file mode 100644 index 0000000..24bdfd9 --- /dev/null +++ b/lib/Weather_OWM.lib.php @@ -0,0 +1,76 @@ + $this->lat, "lon" => $this->lng, "exclude" => "minutely,hourly", "units" => "ca", "lang" => $SETTINGS['language']], ["appid" => $apikey]); + $resp = json_decode($json); + + $currently = new Conditions(); + + $currently->lat = $this->lat; + $currently->lng = $this->lng; + $currently->time = $resp->current->dt; + + $currently->summary = $resp->current->weather->description; + $currently->setDayorNight(); + + $currently->temperature = $resp->current->temp; + $currently->tempFeels = $resp->current->feels_like; + + //$currently->precipProbability = $resp->current->precipProbability; // FIX + + //$currently->ozone = $resp->current->ozone; // FIX + $currently->dewpoint = $resp->current->dew_point; + $currently->cloudCover = $resp->current->clouds; + $currently->humidity = $resp->current->humidity; + $currently->visibility = $resp->current->visibility; + $currently->uvindex = $resp->current->uvi; + + $currently->windSpeed = $resp->current->wind_speed; + $currently->windGust = $resp->current->wind_gust; + $currently->windBearing = $resp->current->wind_deg; + + $this->setCurrently($currently); + + foreach ($resp->daily as $day) { + $daily = new Conditions(); + + $daily->lat = $this->lat; + $daily->lng = $this->lng; + $daily->time = $day->dt; + + $daily->summary = $day->weather->description; + $daily->setDayorNight(); + $daily->disablenight = true; + + $daily->tempHigh = $day->temp->day; + $daily->tempLow = $day->temp->night; + + //$daily->precipProbability = $day->precipProbability; + + //$daily->ozone = $day->ozone; + $daily->dewpoint = $day->dew_point; + $daily->cloudCover = $day->clouds; + $daily->humidity = $day->humidity; + $daily->visibility = $day->visibility; + $daily->uvindex = $day->uvi; + + $daily->windSpeed = $day->wind_speed; + $daily->windGust = $day->wind_gust; + $daily->windBearing = $day->wind_deg; + + $this->conditions[] = $daily; + } + } + +} diff --git a/settings.template.php b/settings.template.php index 53be43b..18195d5 100644 --- a/settings.template.php +++ b/settings.template.php @@ -40,6 +40,7 @@ $SETTINGS = [ "apikeys" => [ "newsapi.org" => "", "darksky.net" => "", + "openweathermap.org" => "", "twitter.com" => [ "consumer_key" => "", "consumer_secret" => "" @@ -51,7 +52,7 @@ $SETTINGS = [ "NewsAPI", "Reddit" ], - "weather" => "DarkSky" + "weather" => "OWM" ], // Location of MaxMind GeoIP database // Required attribution: This product includes GeoLite2 data created by