Given that WeatherUnderground has announced shutoff of the WU API on 31-Dec-2018, I thought it prudent to locate another source for forecasts that still offers free (low volume) access, is multilingual, and international coverage. DarkSky.net fits that with some caveats:
forecasts are for 8 days (including today) and day-only forecasts are available (no night-time specific forecasts), but high/low expected temperatures are included for each day.
The DarkSky text forecast is quite terse (more like an icon description), so the script ‘fleshes out’ the text forecast a bit by adding High/Low temperatures, Chance of Precipitation (if>0%), Wind direction, speed->gust, and UV index to the text.
Because of the latter additions, for internationalization there is a required DS-forecast-lang.php which includes a encoded lookup array for day names+some weather terms in each supported language. All languages supported in the current Saratoga templates are covered (af,bg,cs,ct,de,dk,el,en,es,fi,fr,he,hu,it,nl,no,pl,pt,ro,se,si,sk).
The DS-forecast.php script is for standalone or Saratoga-template usage, and can output the text in either UTF-8 or the ISO-8859-n languages used in the Saratoga templates.
I’ll be doing some work to replace WU-forecast.php with DS-forecast.php in the Base-World template set soon.
You are running on a very old PHP (PHP 5.2.17) and that version had issues with the json_decode() built-in function – The script needs PHP 5.3+ (preferably PHP 5.6 or 7.2).
You can try to get the script working by changing DS-forecast.php from
if(json_last_error() === JSON_ERROR_NONE) { // got good JSON .. process it
$UnSupported = false;
to
if(isset($JSON['daily']['data'][0]['time'])) { // got good JSON .. process it
$UnSupported = false;
I’ve done an update to the DarkSky scripts today (8-Dec-2018) DS-forecast.php V1.05, DS-forecast-lang.php V1.04 that has the following additions:
a new current-conditions block can now be displayed (default is to display it). DarkSky JSON has a current entry with conditions from a nearby station generally available. The Icon, conditions, sunrise/set, distance from forecast point and overall summary are displayed in the block. This is similar to the display with the ec-forecast.php script for Canadian forecasts.
if precipitation is forecast, the type of precip (rain, snow, sleet) also appears in the text forecast like the ‘Chance of precipitation (rain) nn%’.
since DarkSky has a very limited set of icons specified (currently limited to clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night), I’ve added a routine to use the cloud-coverage (converted to octets) to change the clear-, partly-cloudy- specs to use SKC, FEW, SCT, BKN, OVC icons as appropriate. Also, for wind icon, the same cloud-coverage is applied.
Even with these changes, DarkSky continues to use -night icons when talking about full-day forecasts sometimes.
Update is available from the scripts page (update both scripts) and the Template update tool page ( query for 08-Dec-2018, Base-World, *-plugin)