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.

GET request
#2
Use this to get JSON data, change token and url as needed:
Code:
json = require('json')
ltn12 = require('ltn12')
http = require('socket.http')

token = 'ABCDEF'
url = 'https://httpbin.org/get'

resp = {}

res, code = http.request({
  url = url,
  method = 'GET',
  headers = {
    authorization = 'Bearer ' .. token,
  },
  sink = ltn12.sink.table(resp),
})

resp = table.concat(resp)
resp = json.pdecode(resp)

log(resp)

You can store time/value pairs in storage and use a scheduled script that checks if any event should run once a minute.
Reply


Messages In This Thread
GET request - by a455115 - 03.04.2023, 07:09
RE: GET request - by admin - 03.04.2023, 08:58
RE: GET request - by a455115 - 03.04.2023, 11:17
RE: GET request - by admin - 03.04.2023, 11:18
RE: GET request - by a455115 - 04.04.2023, 06:28
RE: GET request - by admin - 04.04.2023, 06:29
RE: GET request - by a455115 - 04.04.2023, 09:37
RE: GET request - by admin - 04.04.2023, 09:39
RE: GET request - by a455115 - 04.04.2023, 10:15

Forum Jump: