Hi,
I've not been coding for some time, so I really appreciate some help.
I'm trying to read an array from an URL but I get an url error.
Here's the code:
TIA
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
#ifndef STASSID
#define STASSID ""
#define STAPSK ""
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* url = "https://www.ebolisa.net/mytime.php";
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
WiFiClient client; // or WiFiClientSecure for HTTPS
HTTPClient http;
// Send request
http.begin(client, url);
http.GET();
// Print the response
Serial.print(http.getString());
// Disconnect
http.end();
}
void loop() {}
Responce:
16:22:10.755 -> WiFi connected
16:22:10.755 -> IP address: 192.168.1.12
16:22:10.802 -> <html>
16:22:10.802 -> <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
16:22:10.802 -> <body>
16:22:10.802 -> <center><h1>400 Bad Request</h1></center>
16:22:10.849 -> <center>The plain HTTP request was sent to HTTPS port</center>
16:22:10.849 -> <hr><center>nginx</center>
16:22:10.849 -> </body>
16:22:10.849 -> </html>
EDIT:
If I use WiFiClientSecure client I get only this a s a response:
16:24:51.221 -> WiFi connected
16:24:51.221 -> IP address: 192.168.1.12