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.

JSON decode
#5
(18.07.2023, 16:10)Dré Wrote: Hi Joep,

Will you share how you did the rest done, like request the for the right postcode/place?

Hi Dré,
First you need to check if this API is available for your address. See if you get info when adding your zipcode and house number to this url https://mijnafvalwijzer.nl/

If it works you can use the script below:

Code:
require('socket.http')
json = require('json')
socket.http.TIMEOUT = 5

data = socket.http.request('https://api.mijnafvalwijzer.nl/webservices/appsinput/?apikey=YOUR-API-KEY-HERE&method=postcodecheck&postcode=YOUR_ZIPCODE_HERE&street=&huisnummer=YOUR-HOUSE-NUMBER-HERE&toevoeging=&app_name=afvalwijzer&platform=phone&afvaldata=' .. os.date("%Y") .. '-01-01&langs=nl')

data = json.pdecode(data)

for key, value in pairs(data.ophaaldagen.data) do
  if value.date == os.date("%Y-%m-%d") then
    if value.nameType == "restafval" then
      log("grijze kliko")
    elseif value.nameType == "gft" then
      log("groene kliko")
    elseif value.nameType == "plastic" then
      log("plastic afval")
    end
  end
end
Reply


Messages In This Thread
JSON decode - by Joep - 05.07.2023, 15:28
RE: JSON decode - by Erwin van der Zwart - 06.07.2023, 06:15
RE: JSON decode - by Joep - 06.07.2023, 13:51
RE: JSON decode - by Dré - 18.07.2023, 16:10
RE: JSON decode - by Joep - 19.07.2023, 12:58

Forum Jump: