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.

Openweather api
#22
Excuse me, here it is.
Code:
require('json')                                    
require('ssl.https')                        

appid = 'xxxxxxxxxxxxxxxxxxx'    
lat = 'xxxxx'                                                            
lon ='xxxxx'                                                            
lang = 'es'                                                                    

url = 'https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&units=%s&lang=%s&appid=%s'        
url = string.format(url, lat, lon, units, lang, appid)                                                                                        

JSON_Tiempo, error = ssl.https.request(url)                                                                                                                

log(url, JSON_Tiempo, error)                                                                                                                                            

Tabla_tiempo = json.pdecode(JSON_Tiempo)                                                                                                            
                                                                                                                                                                                            


if type(Tabla_tiempo) ~= 'table' then                                                                                                                    
  alert('Fallo al cargar la información del tiempo de Openweather')                                                        
elseif Tabla_tiempo.cod == 401 then                                                                                                                        
  alert('Fallo con la llave de la API de Openweather')                                                                                

  elseif Tabla_tiempo.cod == 404 then
  alert('Fallo en la solicitud de la API de Openweather')
  elseif Tabla_tiempo.cod == 429 then
  alert('Fallo por exceder el límite de llamadas a la API de Openweather')
  return
end


Tiempo_actual = Tabla_tiempo.current
log(Tiempo_actual)


grp.write('32/2/10', Tiempo_actual.temp)                                                                                                            

grp.write('32/2/11', Tiempo_actual.feels_like)


grp.write('32/2/12', Tiempo_actual.dew_point)


grp.write('32/2/13', Tiempo_actual.wind_deg)


grp.write('32/2/14', Tiempo_actual.wind_speed)


grp.write('32/2/15', Tiempo_actual.humidity)


grp.write('32/2/16', Tiempo_actual.pressure)


grp.write('32/2/17', Tiempo_actual.uvi)


grp.write('32/2/18', Tiempo_actual.weather[1].description)


amanecer = os.date("%H:%M", Tiempo_actual.sunrise)
grp.write('32/2/19', amanecer)


ocaso = os.date("%H:%M", Tiempo_actual.sunset)
grp.write('32/2/20', ocaso)
Reply


Messages In This Thread
Openweather api - by JRP - 20.07.2020, 11:13
RE: Openweather api - by admin - 20.07.2020, 11:16
RE: Openweather api - by JRP - 20.07.2020, 11:49
RE: Openweather api - by admin - 20.07.2020, 11:53
RE: Openweather api - by JRP - 20.07.2020, 15:43
RE: Openweather api - by JRP - 01.09.2020, 16:32
RE: Openweather api - by admin - 01.09.2020, 16:50
RE: Openweather api - by JRP - 02.09.2020, 11:01
RE: Openweather api - by admin - 02.09.2020, 11:09
RE: Openweather api - by victor.back - 14.11.2020, 20:37
RE: Openweather api - by JRP - 02.09.2020, 11:20
RE: Openweather api - by admin - 02.09.2020, 11:22
RE: Openweather api - by JRP - 02.09.2020, 11:41
RE: Openweather api - by Daniel - 02.09.2020, 11:43
RE: Openweather api - by JRP - 02.09.2020, 12:12
RE: Openweather api - by admin - 15.11.2020, 09:05
RE: Openweather api - by victor.back - 15.11.2020, 20:10
RE: Openweather api - by admin - 16.11.2020, 07:40
RE: Openweather api - by victor.back - 01.01.2021, 21:07
RE: Openweather api - by JRP - 19.04.2021, 10:20
RE: Openweather api - by admin - 19.04.2021, 10:23
RE: Openweather api - by JRP - 19.04.2021, 10:31
RE: Openweather api - by admin - 19.04.2021, 10:33
RE: Openweather api - by JRP - 19.04.2021, 10:38
RE: Openweather api - by admin - 19.04.2021, 10:41
RE: Openweather api - by JRP - 19.04.2021, 10:47
RE: Openweather api - by admin - 19.04.2021, 10:53
RE: Openweather api - by JRP - 19.04.2021, 11:04
RE: Openweather api - by davidchispas - 21.07.2021, 10:34
RE: Openweather api - by Daniel - 21.07.2021, 10:51
RE: Openweather api - by JRP - 30.08.2022, 10:28
RE: Openweather api - by admin - 30.08.2022, 10:29
RE: Openweather api - by JRP - 08.09.2022, 09:47

Forum Jump: