19.07.2023, 12:58
(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