Étape 6: Code de l’Agent
Maintenant, voici le code de l’Agent. NOTE!: n’oubliez pas de mettre votre propre ID de jeton et Variable dans l’appel HTTP :
<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>