Stap 6: Agent Code
Nu, hier is de code van de Agent. Opmerking!: Vergeet niet om uw eigen token en variabele-ID in de HTTP-oproep:
<br><p>device.on("temp", function(value) {<br> server.log("Trying to post to Ubi the value:"); server.log(value); local headers = { "Content-Type": "application/json", "X-Auth-Token": "NBbF3PWPxWc2IaO40aXOKnhIu8tOv92rYN3ibiEc7Jh6GV3KZUUCHtXuNz7Y" }; // Replace the token with yours local url = "http://things.ubidots.com/api/v1.6/variables/53d2beb37625424630223dac/values"; // Replace the Variable ID with yours local string = {"value": value}; local request = http.post(url, headers, http.jsonencode(string)); local response = request.sendsync(); });</p>