#include <WiFi.h>
#include <WiFiClientSecure.h>
const char* host = "script.google.com";
const int httpsPort = 443; // Standard HTTPS port
void setup() {
Serial.begin(9600);
WiFi.begin("Wokwi-GUEST");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting...");
}
Serial.println("Connected");
}
void loop() {
WiFiClientSecure client;
client.setInsecure();
// Use HTTPS for a secure connection
if (client.connect(host, httpsPort)) {
Serial.println("Connected to the server");
// Add your parameters to the payload
String url = "/macros/s/AKfycbxxp0zzEemC02YY94FMjsk050idLwL5VqDd25L_tqA8SHc5j0pDxvPn-X8qeFnfOm0/exec";
String payload = "value1=Hello&value2=World"; // Adjust as needed
// Show the full link before making the request
Serial.print("Full URL: ");
Serial.println("https://" + String(host) + url + "?" + payload);
// Send GET request with payload
client.print(String("GET ") + url + "?" + payload + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500); // Allow time for the server to process
// Read and print the response
while (client.available()) {
char c = client.read();
Serial.print(c);
}
Serial.println(); // Add a new line for better readability
// End client connection
client.stop();
} else {
// Show the full link when unable to connect
Serial.print("Unable to connect to the server. Full URL: ");
Serial.println("https://" + String(host) + "/macros/s/AKfycbxxp0zzEemC02YY94FMjsk050idLwL5VqDd25L_tqA8SHc5j0pDxvPn-X8qeFnfOm0/exec");
}
delay(5000); // Wait for 5 seconds before sending the next request
}