https request in LUA for DarkSky forecast
Posted: Wednesday 12 December 2018 19:01
As Weather Underground will stop its free service soon I am trying to adapt my lua scripts to use forecast data from DarkSky.
The DarkSky API works only with https requests. Thus I only get the reply "Bad Request" instead of the JSON reply if I use the following code to access the DarkSky forecast.
Of course I replaced the [] section with my own data.
How can I make a https request in lua (I am still using Domoticz V3.5877 for other compatibility reasons)?
The DarkSky API works only with https requests. Thus I only get the reply "Bad Request" instead of the JSON reply if I use the following code to access the DarkSky forecast.
Code: Select all
io = require('io')
http = require('socket.http')
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
reply = http.request("https://api.darksky.net/forecast/[APIcode]/[lat],[lon]?units=si")
print(reply)
How can I make a https request in lua (I am still using Domoticz V3.5877 for other compatibility reasons)?