Client.print to POST request to web URL fails
Posted: Mon Jan 25, 2016 5:25 pm
Hi
I have a ESP8266 connected to my network and serving a webpage. That part is working just fine.
I want to add a function: void sendMessage() that will post to ifttt.com but I can't get it working right.
I tried this:
But it doesn't work... the IFTTT recipe is not being triggered.
Any help is appreciated.
Thanks
I have a ESP8266 connected to my network and serving a webpage. That part is working just fine.
I want to add a function: void sendMessage() that will post to ifttt.com but I can't get it working right.
I tried this:
Code: Select all
WiFiClient Client;
// IFTTT message setting
String ifttt_url = "/trigger/temperatur_for_lav/with/key/d7i**********lThq2DB2i";
String ifttt_host = "maker.ifttt.com";
sensors.requestTemperatures(); // Send the command to get temperatures
sensor1_temp = sensors.getTempCByIndex(0);
if ( sensor1_temp > 28 ) {
Client.print(String("POST ") + ifttt_url + "&headers=false" + " HTTP/1.1\r\n" + "Host: " + ifttt_host + "\r\n" + "Connection: close\r\n\r\n");
}
But it doesn't work... the IFTTT recipe is not being triggered.
Any help is appreciated.
Thanks