27.07.2020, 19:10
Hi,
service yr.no now use new API and advice use .json format for weather data reading. .xml will not supported anymore from start of the next year.
Info here: https://developer.yr.no/doc/
May be some created script based on .json and new API?
I just tried to read data for me and receive error:
link to info with .json: https://api.met.no/weatherapi/locationfo...ltitude=13
Script I tried to read data:
I received such error:
* string: 403 Forbidden
User-Agent header LuaSocket 2.0.2 is not allowed, use a unique identifier
What is incorrect in my trying?
BR,
Alex
service yr.no now use new API and advice use .json format for weather data reading. .xml will not supported anymore from start of the next year.
Info here: https://developer.yr.no/doc/
May be some created script based on .json and new API?
I just tried to read data for me and receive error:
link to info with .json: https://api.met.no/weatherapi/locationfo...ltitude=13
Script I tried to read data:
Code:
require('json')
https = require('ssl.https')
escape = require('socket.url').escape
url = 'https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=67.8596&lon=35.0904&altitude=13'
url = string.format(url)
res = https.request(url)
log(res)
data = json.pdecode(res)
log(data)
if type(data) ~= 'table' then
alert('failed to load weather data')
return
end
if data.error then
log('error', data.error)
return
end
I received such error:
* string: 403 Forbidden
User-Agent header LuaSocket 2.0.2 is not allowed, use a unique identifier
What is incorrect in my trying?
BR,
Alex