#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "******";
const char* password = "*******";
void setup() {
Serial.begin(115200);
//TESTING JSON CREATION
Serial.println("Starting JSON");
StaticJsonBuffer<69> jsonBuffer;
char json[] = "{\"Rfid_ID\":\"E54CEB2361\",\"Door_ID\":\"6\"}"; // göndereceğimiz bilginin yazılışı istenilene göre
JsonObject& root = jsonBuffer.parseObject(json);
if(!root.success()) {
Serial.println("parseObject() failed");
} else {
Serial.println("JSON OK");
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print("Connecting... ");
}
//TESTING POST
//headers={'content-type': 'application/json', 'auth-key': 'My_authentication_key'}
String sms_service_URL = "link yazıyoruz";
Serial.println("TESTING POST");
//Declare an object of class HTTPClient
WiFiClient client;
HTTPClient http;
if (WiFi.status() == WL_CONNECTED) {
//Specify request destination
http.begin(client,sms_service_URL);
http.addHeader("Content-Type", "application/json");
http.addHeader("auth-key", "My_authentication_key");
String data;
root.printTo(data);
//Send the request
int httpCode = http.POST(data);
//Check the returning code
if (httpCode > 0) {
//Get the request response payload
String payload = http.getString();
//Print the response payload
Serial.println(payload);
}
//Close connection
http.end();
Serial.println(httpCode);
}
}
void loop() {
}