Hi!
How could I get the page body content (without the headers?) I am requesting a php page, which I want to read back some text data. The httpResponseCode, returns a number only.. or not?
unsigned int httpResponseCode =
wifi.GET
(
F(reqIP), // The IP address of the server you want to contact
80, // The Port to Connect to (80 is the usual "http" port)
buffer, // Your buffer which currently contains the path to request
sizeof(buffer), // The size of the buffer
F(reqPage), // Optional hostname you are connecting to(* see below)
0 // Get from line 2 of the body, no headers (use 0 to get headers)
// responses often have a leading newline, hence starting
// from line 2 here, adjust as necessary
);
if(httpResponseCode == 200 || httpResponseCode == ESP8266_OK) {
// Our request was successfull and the response can be found in the buffer
Serial.println(F("OK"));
Serial.println(buffer);
}
Also, could I have 2-3 different wifi credentials, and when the server cannnot connect, it would switch to the next combination, and rotate until it is connected? example:
String wifiCodes[][3] = {
{ "ssid1","pwd1"},
{"ssid2","pwd2" },
{"ssid3","pwd3" }
};
Thanks a lot for the code, and all the effort :-)
Panos
Hi!
How could I get the page body content (without the headers?) I am requesting a php page, which I want to read back some text data. The httpResponseCode, returns a number only.. or not?
unsigned int httpResponseCode =
wifi.GET
(
F(reqIP), // The IP address of the server you want to contact
80, // The Port to Connect to (80 is the usual "http" port)
buffer, // Your buffer which currently contains the path to request
sizeof(buffer), // The size of the buffer
F(reqPage), // Optional hostname you are connecting to(* see below)
0 // Get from line 2 of the body, no headers (use 0 to get headers)
// responses often have a leading newline, hence starting
// from line 2 here, adjust as necessary
);
if(httpResponseCode == 200 || httpResponseCode == ESP8266_OK) {
// Our request was successfull and the response can be found in the buffer
Serial.println(F("OK"));
Serial.println(buffer);
}
Also, could I have 2-3 different wifi credentials, and when the server cannnot connect, it would switch to the next combination, and rotate until it is connected? example:
String wifiCodes[][3] = {
{ "ssid1","pwd1"},
{"ssid2","pwd2" },
{"ssid3","pwd3" }
};
Thanks a lot for the code, and all the effort :-)
Panos