Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By zioax
#29675 I'm tring to make a GET request to a php file running in a localhost machine, but without success.
This is the code:
Code: Select all/*
 *  This sketch sends data via HTTP GET requests to data.sparkfun.com service.
 *
 *  You need to get streamId and privateKey at data.sparkfun.com and paste them
 *  below. Or just customize this script to talk to other HTTP servers.
 *
 */

#include <ESP8266WiFi.h>

const char* ssid     = "ssid";
const char* password = "password";

const char* host = "192.168.1.10";

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}



void loop() {
  delay(5000);
 
  Serial.print("connecting to ");
  Serial.println(host);
 
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  client.connect(host, httpPort);
 
  // We now create a URI for the request
  String url = "/wa/examples/wa1.php";


 

 
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +

               "Host: " + host + "\r\n" +
               "Accept: */*\r\n" +
               "User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n" +
               "\r\n"
               
               );
  delay(100);
 
  // Read all the lines of the reply from server and print them to Serial

}

The code work well from the browser, so it isn't a server side issue
User avatar
By martinayotte
#29676 At first look, I don't any thing special here.

Code: Select all  // Read all the lines of the reply from server and print them to Serial


Instead of this comment, do you have some code which really print the reply ?
What is the content of this reply ?