Skip to content

GET to return the webpage body #9

@sincetomorrow

Description

@sincetomorrow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions