Unable to get url info

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

It looks like you're trying to use a plain client to access a secure link (https). Look at the comments in your code which tell you how to hit https instead.

Oh yes, I did try that but I get no response at all.

What happens if you hit the site from a browser?

I get: [15,16,17,7,4,122,6,126,1]

I'd get one of the basic examples that come with the secure library and point it at your web site. It might also be worth checking the logs on the server if you have access to them.

Will do, thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.