This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Weather service not working anymore?
#73
(30.08.2019, 06:16)admin Wrote: This is probably due to older FW, as a work-around you can use HTTP request instead:

Code:
require('json')
http = require('socket.http')
escape = require('socket.url').escape

key = 'my_api_key'
location = 'my location name'

url = 'http://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(location))

res = http.request(url)

data = json.pdecode(res)
...

Weather service is working, but from different url 

url = 'http://api.weatherstack.com/current?access_key=%s&query=%s'

will return table data.current like this

* table:
["cloudcover"]
  * number: 59
["visibility"]
  * number: 10
["observation_time"]
  * string: 12:24 PM
["uv_index"]
  * number: 5
["wind_dir"]
  * string: NNW
["humidity"]
  * number: 60
["weather_descriptions"]
  * table:
  [1]
    * string: Cloudy
["wind_speed"]
  * number: 21
["weather_code"]
  * number: 119
["is_day"]
  * string: yes
["pressure"]
  * number: 1017
["precip"]
  * number: 0.1
["weather_icons"]
  * table:
  [1]
    * string: https://assets.weatherstack.com/images/w..._cloud.png
["feelslike"]
  * number: 10
["temperature"]
  * number: 12
["wind_degree"]
  * number: 327

Best regards
Alex
Reply


Messages In This Thread
RE: Weather service not working anymore? - by alexgleyzer - 08.05.2020, 12:50

Forum Jump: