20.09.2023, 10:39
Try this, replace ... with real values for siteid / siteAuthenticationKey / softwaretype:
Code:
escape = require('socket.url').escape
function encode(t)
local res = {}
for k, v in pairs(t) do
res[ #res + 1 ] = tostring(k) .. '=' .. tostring(v)
end
return table.concat(res, '&')
end
qs = encode({
dateutc = os.date('!%Y-%m-%d+%H%%3A%M%%3A%S'),
siteid = escape('...'),
siteAuthenticationKey = escape('...'),
softwaretype = escape('...'),
tempc = grp.getvalue('32/1/5'),
dailyrainin = grp.getvalue('32/1/31'),
winddir = grp.getvalue('32/1/3'),
rainin = grp.getvalue('32/1/30'),
windspeedmph = grp.getvalue('32/1/1'),
humidity = grp.getvalue('32/1/11'),
windgustmph = grp.getvalue('32/1/2'),
baromin = grp.getvalue('32/1/15'),
})
url = 'https://wow.metoffice.gov.uk/automaticreading?' .. qs
log(url)
res, err = require('socket.http').request(url)
log(res, err)