WU-forecast.php not working correctly

Hi Ken,

Seems the WU api has finally died - some time today my wxforecast.php started to coming back with errors.

I looked at my API key on WU and it seemed to have been deleted, so I had to create a new one.

I then looked at the new API documentation https://docs.google.com/document/d/1RY44O8ujbIA_tjlC4vYKHKzwSwEmNxuGw5sEJ9dYjG4/edit and found I can get json data using a different url using a 5 day forecast.

If I use my lat/long and browse to https://api.weather.com/v3/wx/forecast/daily/5day?geocode=-34.75,150.82&format=json&units=e&language=en-US&apiKey=yourApiKey

I get valid json

{"dayOfWeek":["Thursday","Friday","Saturday","Sunday","Monday","Tuesday"],"expirationTimeUtc":[1554978404,1554978404,1554978404,1554978404,1554978404,1554978404],"moonPhase":["Waxing Crescent","Waxing Crescent","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous","Waxing Gibbous"],"moonPhaseCode":["WXC","WXC","WXG","WXG","WXG","WXG"],"moonPhaseDay":[5,6,8,9,10,11],"moonriseTimeLocal":["2019-04-11T11:40:22+1000","2019-04-12T12:38:52+1000","2019-04-13T13:34:19+1000","2019-04-14T14:23:57+1000","2019-04-15T15:09:27+1000","2019-04-16T15:50:27+1000"],"moonriseTimeUtc":[1554946822,1555036732,1555126459,1555215837,1555304967,1555393827],"moonsetTimeLocal":["2019-04-11T21:54:06+1000","2019-04-12T22:51:34+1000","2019-04-13T23:55:01+1000","","2019-04-15T01:02:09+1000","2019-04-16T02:11:07+1000"],"moonsetTimeUtc":[1554983646,1555073494,1555163701,null,1555254129,1555344667],"narrative":["Partly cloudy. Lows overnight in the mid 50s.","More sun than clouds. Highs in the low 70s and lows in the upper 50s.","Mix of sun and clouds. Highs in the mid 70s and lows in the low 60s.","A few morning showers. Highs in the low 70s and lows in the low 60s.","Mix of sun and clouds. Highs in the low 70s and lows in the upper 50s.","Plenty of sun. Highs in the low 70s and lows in the low 60s."],"qpf":[0.0,0.0,0.0,0.06,0.0,0.0],"qpfSnow":[0.0,0.0,0.0,0.0,0.0,0.0],"sunriseTimeLocal":["2019-04-11T06:16:17+1000","2019-04-12T06:17:03+1000","2019-04-13T06:17:50+1000","2019-04-14T06:18:36+1000","2019-04-15T06:19:23+1000","2019-04-16T06:20:09+1000"],"sunriseTimeUtc":[1554927377,1555013823,1555100270,1555186716,1555273163,1555359609],"sunsetTimeLocal":["2019-04-11T17:39:12+1000","2019-04-12T17:37:54+1000","2019-04-13T17:36:36+1000","2019-04-14T17:35:20+1000","2019-04-15T17:34:03+1000","2019-04-16T17:32:48+1000"],"sunsetTimeUtc":[1554968352,1555054674,1555140996,1555227320,1555313643,1555399968],"temperatureMax":[null,70,74,71,71,72],"temperatureMin":[56,57,60,60,59,60],"validTimeLocal":["2019-04-11T07:00:00+1000","2019-04-12T07:00:00+1000","2019-04-13T07:00:00+1000","2019-04-14T07:00:00+1000","2019-04-15T07:00:00+1000","2019-04-16T07:00:00+1000"],"validTimeUtc":[1554930000,1555016400,1555102800,1555189200,1555275600,1555362000],"daypart":[{"cloudCover":[null,28,37,2,43,59,54,65,43,43,36,20],"dayOrNight":[null,"N","D","N","D","N","D","N","D","N","D","N"],"daypartName":[null,"Tonight","Tomorrow","Tomorrow night","Saturday","Saturday night","Sunday","Sunday night","Monday","Monday night","Tuesday","Tuesday night"],"iconCode":[null,29,34,31,30,29,39,11,30,29,34,33],"iconCodeExtend":[null,2900,3400,3100,3000,2900,6103,1100,3000,2900,3400,3300],"narrative":[null,"Clear to partly cloudy. Low 56F. Winds WSW at 5 to 10 mph.","A few passing clouds, otherwise generally sunny. High around 70F. W winds shifting to NE at 10 to 20 mph.","Clear skies. Low 57F. Winds NNW at 10 to 15 mph.","Intervals of clouds and sunshine in the morning with more clouds for later in the day. High 74F. W winds shifting to SE at 10 to 15 mph.","A few clouds. Low near 60F. Winds SW at 5 to 10 mph.","Showers in the morning, then partly cloudy in the afternoon. High 71F. Winds S at 10 to 15 mph. Chance of rain 40%.","Cloudy with showers. Low near 60F. Winds WSW at 5 to 10 mph. Chance of rain 40%.","Partly cloudy. High 71F. SW winds shifting to E at 10 to 15 mph.","A few clouds from time to time. Low 59F. Winds NW at 5 to 10 mph.","Sun and a few passing clouds. High 72F. NNW winds shifting to ENE at 10 to 15 mph.","Mostly clear. Low near 60F. Winds NNW at 5 to 10 mph."],"precipChance":[null,10,10,10,10,10,40,40,20,20,20,20],"precipType":[null,"rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],"qpf":[null,0.0,0.0,0.0,0.0,0.0,0.02,0.03,0.0,0.0,0.0,0.0],"qpfSnow":[null,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"qualifierCode":[null,null,null,null,null,null,null,null,null,null,null,null],"qualifierPhrase":[null,null,null,null,null,null,null,null,null,null,null,null],"relativeHumidity":[null,83,66,82,63,85,70,85,69,85,70,86],"snowRange":[null,"","","","","","","","","","",""],"temperature":[null,56,70,57,74,60,71,60,71,59,72,60],"temperatureHeatIndex":[null,59,69,64,74,66,70,65,71,64,72,65],"temperatureWindChill":[null,56,57,57,59,59,61,60,61,59,61,61],"thunderCategory":[null,"No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder","No thunder"],"thunderIndex":[null,0,0,0,0,0,0,0,0,0,0,0],"uvDescription":[null,"Low","Moderate","Low","Moderate","Low","Moderate","Low","Moderate","Low","Moderate","Low"],"uvIndex":[null,0,5,0,5,0,5,0,5,0,5,0],"windDirection":[null,258,43,331,182,236,187,241,145,309,36,332],"windDirectionCardinal":[null,"WSW","NE","NNW","S","SW","S","WSW","SE","NW","NE","NNW"],"windPhrase":[null,"Winds WSW at 5 to 10 mph.","W winds shifting to NE at 10 to 20 mph.","Winds NNW at 10 to 15 mph.","W winds shifting to SE at 10 to 15 mph.","Winds SW at 5 to 10 mph.","Winds S at 10 to 15 mph.","Winds WSW at 5 to 10 mph.","SW winds shifting to E at 10 to 15 mph.","Winds NW at 5 to 10 mph.","NNW winds shifting to ENE at 10 to 15 mph.","Winds NNW at 5 to 10 mph."],"windSpeed":[null,6,13,10,10,9,11,7,11,6,11,6],"wxPhraseLong":[null,"Partly Cloudy","Mostly Sunny","Clear","Partly Cloudy","Partly Cloudy","AM Showers","Showers","Partly Cloudy","Partly Cloudy","Mostly Sunny","Mostly Clear"],"wxPhraseShort":[null,"P Cloudy","M Sunny","Clear","P Cloudy","P Cloudy","AM Showers","Showers","P Cloudy","P Cloudy","M Sunny","M Clear"]}]}

However, in wxforecast.php if I replace

$newURL = 'http://api.wunderground.com/api/%s/forecastday/geolookup/lang:%s/q/%s.json'; 

with

 $newURL = 'https://api.weather.com/v3/wx/forecast/daily/5day?geocode=-34.75,150.82&format=json&units=e&language=en-US&apiKey=yourApiKey';

I still get errors so maybe the json formatting is now different?

Many tahnks
Ian

Yes, the old WU API has been turned off, and the WU-forecast.php script is now dead (and deprecated).

The replacement API (the new WU/TWC API) is incompatible/differently formatted with WU-forecast.php. A new script WC-forecast.php was created to use the new API – you should use http://wx.theshackbythebeach.com/wx/check-fetch-times.php?show=versions to show what needs updating, and after you have the latest check-fetch-times.php (V1.25 - 2019-03-01) installed, run it again to get the complete list of files needing updates.