Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By jimthree
#18724
tytower wrote:http://www.esp8266.com/viewtopic.php?f=6&t=2872&p=18357#p18357

In there there is a postData function to Sparkfuns server




Thanks tytower, but that appears to be a GET request, not a POST.

Jim
User avatar
By Stephen
#18992 This may help:

Code: Select allvoid post()
{
  WiFiClient client;
  String PostData = "temp=1";
  client.println("POST /index.php HTTP/1.1");
  client.println("Host: ***EDIT*** your-end-domain.com***EDIT***");
  client.println("User-Agent: Arduino/1.0");
  client.println("Connection: close");
  client.println("Content-Type: application/x-www-form-urlencoded;");
  client.print("Content-Length: ");
  client.println(PostData.length());
  client.println();
  client.println(PostData);
  delay(10);

  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }
}