I have an embarrassingly simple app based upon the LED example. I needed to confirm I could do a PUT so I can post machine data to GroveStreams (similar to Xively). My code was working 2 weeks ago, but it doesn’t seem to be working today. I looked for other similar posts, but can see none (sorry if this is already explained). Everything in system.log looks fine.
I’ve “tweaked” the domain to prevent massive emails from hitting my inbox.
`// Log the URLs we need
server.log("Turn LED On: " + http.agenturl() + “?led=1”);
server.log("Turn LED Off: " + http.agenturl() + “?led=0”);
const myURL = “http://www.xxxx.com/tomstest/testmail.php”;
function requestHandler(request, response) {
try {
// check if the user sent led as a query parameter
if (“led” in request.query) {
server.log("we’re processing a request! ");
// if they did, and led=1… set our variable to 1
if (request.query.led == “1” || request.query.led == “0”) {
// convert the led query parameter to an integer
local ledState = request.query.led.tointeger();
// send "led" message to device, and send ledState as the data
device.send("led", ledState);
}
}
// send a response back saying everything was OK.
response.send(200, "OK");
local fred = MakeCall(myURL);
server.log("Fred is: " + fred);
} catch (ex) {
response.send(500, "Internal Server Error: " + ex);
}
// Basic wrapper to create an execute an HTTP GET
}
function MakeCall (url) {
server.log(“Sending testmail call now”);
server.log(url);
local request = http.get(url, {});
server.log(“just made the call”);
local response = request.sendsync();
return response;
}
// register the HTTP handler
http.onrequest(requestHandler);`