I've read several other posts but I still couldn't solve the issue. I'm trying to connect to a website which is HTTP (not HTTPS) but I always get code -1 as response. If I open the link in the browser it works well. Not sure what I am missing? Here's my full code:
#include <ESP8266HTTPClient.h>
#include <esp8266wifi.h>
const char* ssid = "";
const char* password = "";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print("Connecting..");
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("www.francescosoave.com/blind/getTime.php");
http.addHeader("Content-Type", "text/html");
int httpCode = http.GET();
Serial.print("HTTP CODE: ");
Serial.println(httpCode);
if(httpCode > 0){
String payload = http.getString();
Serial.print("PAYLOAD: ");
Serial.println(payload);
}
http.end();
}
delay(2000);
}