#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include "AnotherIFTTTWebhook.h"
#include "WiFi_Credentials.h"

#define IFTTT_API_KEY "jF1DREiJnO7lXPWoqcyIGb6OpMe8ANPsXBrGeJ6L41B"
#define IFTTT_EVENT_NAME "button_pressed"
#define USERNAME "Tobi"

HTTPClient http;  //Declare an object of class HTTPClient

// Buttons on D3 & D4
const int button1 = 0;
const int button2 = 2;

void setup () {
 
  Serial.begin(115200);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting...");
  }
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}
 
void loop() {
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    int button1Val = digitalRead(button1);
    int button2Val = digitalRead(button2);
    
    if (button1Val == LOW) { 
      // Send POST Request to Webook from IFTTT
      // (EVENT, KEY, Value1, Value2, Value3)
      send_webhook(IFTTT_EVENT_NAME, IFTTT_API_KEY, "Ich bin anwesend", USERNAME, "");
    }

    if (button2Val == LOW) { 
      
    }
 
  }
}