I will preface that I am a noobie. I have my arduino wifi rev2 connecting successfully with my wifi and I am able to get events sent to my email via IFTTT webhooks, but I am having trouble figuring out how to get a value based on a variable sent to myself rather than text. If you see in the code below, where I commented beside, I can send that text to my email, but I want it to be a variable based on a sensor I have.
I realize it says String, which I think may be a problem, but I'm unsure how to write it to send the variable either :\ TIA
void send_event(const char *event)
{
Serial.print("Connection to ");
Serial.println(IFTTT_HOST);
WiFiClient client;
const int httpPort = 80;
if(!client.connect(IFTTT_HOST, httpPort))
{
Serial.print("Connection failed");
return;
}
String url = "/trigger/";
url += event;
url += "/with/key/";
url += IFTTT_KEY;
String mJson = String("{\"value1\":\"") + "I want a variable here instead\" }"; // ISSUE IS RIGHT HERE
Serial.print("Requesting URL: ");
Serial.println(url);
client.println(String("POST ") + url + " HTTP/1.1");
client.println(String("Host: ") + IFTTT_HOST);
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(mJson.length());
client.println();
client.println(mJson);
while(client.connected())
{
if(client.available())
{
String line = client.readStringUntil('\r');
Serial.print(line);
}else{delay(50);};
}
Serial.println();
Serial.println("closing connection");
client.stop();
}