interactive-matter / HTTPClient

An Arduino HTTP Client
https://interactive-matter.eu/how-to/arduino-http-client-library/
101 stars 33 forks source link

Create a GET request #17

Closed phonicmouse closed 8 years ago

phonicmouse commented 8 years ago

@interactive-matter @Apollon77 how to do that? Please help me..

Apollon77 commented 8 years ago

Very simple:

HTTPClient client("IP", PORT); //client.debug(1);

// FILE is the return STREAM type of the HTTPClient char Uri[255]="..."; FILE* result = client.getURI(Uri);

int returnCode = client.getLastReturnCode();

if (returnCode==NULL) { //Error }

if (result!=NULL) { int c; response=""; while ((c = fgetc(result)) != EOF) { response+=(char) c; //Serial.print((char) c); } if (ferror(result)) { //error }

//Serial.println("");
client.closeStream(result);  // this is very important -- be sure to close the STREAM

}

phonicmouse commented 8 years ago

thanks.

phonicmouse commented 8 years ago

@Apollon77 only one thing...where do you get the response char?

Apollon77 commented 8 years ago

response is simply declared as String

phonicmouse commented 8 years ago

ok thanks ;)