Bonjour,
J'ai, pour l'exemple, une page web https://e-emploi.be/ toute simple en php avec $_GET. Essayez par exemple https://e-emploi.be/?cle=123456 elle s'affiche tout en haut à gauche
Je me connecte correctement au réseau local, mais pas moyen d’accéder au serveur :
Connecting to Renard_16
...........WiFiCon=1
WiFi connected
IP address:
192.168.0.98
>>> Connecting to host: e-emploi.be
**HTTP/1.1 400 Bad Request**
>>> Closing host: e-emploi.be
Voici la partie du code concernée.
Autre chose gênante, on ne peut que se connecter qu'au domaine et pas à une page précise. Cela limite pas mal !
Un grand merci !
esp8266_essai_GET.ino (2.5 KB)
// IP or name of address root: ie: google.com
// NOT google.com/nothing/after/the/dotcom.html
const char* hostGet = "e-emploi.be";
void postData() {
WiFiClient clientGet;
const int httpGetPort = 80;
// We now create and add parameters:
String urlGet = "?cle=123456";
Serial.print(">>> Connecting to host: ");
Serial.println(hostGet);
if (!clientGet.connect(hostGet, httpGetPort)) {
Serial.print("Connection failed: ");
Serial.print(hostGet);
} else {
clientGet.println("GET " + urlGet + " HTTP/1.1");
clientGet.print("Host: ");
clientGet.println(hostGet);
clientGet.println("User-Agent: ESP8266/1.0");
clientGet.println("Connection: close\r\n\r\n");
unsigned long timeoutP = millis();
while (clientGet.available() == 0) {
if (millis() - timeoutP > 10000) {
Serial.print(">>> Client Timeout: ");
Serial.println(hostGet);
clientGet.stop();
return;
}
}
//just checks the 1st line of the server response. Could be expanded if needed.
while (clientGet.available()) {
String retLine = clientGet.readStringUntil('\r');
Serial.println(retLine);
break;
}
} //end client connection if else
Serial.print(">>> Closing host: ");
Serial.println(hostGet);
clientGet.stop();
}