Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET to return the webpage body #9

Open
sincetomorrow opened this issue Oct 8, 2015 · 0 comments
Open

GET to return the webpage body #9

sincetomorrow opened this issue Oct 8, 2015 · 0 comments

Comments

@sincetomorrow
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant