Sending GET/POST request from ESP8266+Arduino
Posted: Thu Oct 01, 2015 11:50 am
(using arduino uno, esp8266, Arduino 1.6.5 sketch)
I am trying to send GET request through AT command, here are my commands bellow;
AT+CWJAP="*******","*******"
AT+CIPSTART="TCP","shotlu.usrs0.com",80
AT+CIPSEND=73 (length of the url)
>GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\n
*******************************/\******************************
But after sending the url it's giving me this message;
GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\nbusy s...
SEND OK
+IPD,168:<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>hosting</center>
</body>
</html>
OK
CLOSED
OK
any guess why this happened?
******************************/\*********************************
I used this php code for saving data to a text file(basically "GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\n" it will hit this php file and after that this php file will update a Text file)
<?php
$var1 = $_GET['apples'];
$var2 = $_GET['oranges'];
$fileContent = "You have ".$var1." apples, and ".$var2." oranges.\n";
$fileStatus = file_put_contents('myFile.txt',$fileContent,FILE_APPEND);
if($fileStatus != false)
{
echo "success: data written to file";
}
else
{
echo "FAIL: could not write to file";
}
?>
I am trying to send GET request through AT command, here are my commands bellow;
AT+CWJAP="*******","*******"
AT+CIPSTART="TCP","shotlu.usrs0.com",80
AT+CIPSEND=73 (length of the url)
>GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\n
*******************************/\******************************
But after sending the url it's giving me this message;
GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\nbusy s...
SEND OK
+IPD,168:<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>hosting</center>
</body>
</html>
OK
CLOSED
OK
any guess why this happened?
******************************/\*********************************
I used this php code for saving data to a text file(basically "GET /receiver.php?apples=56&oranges=23 HTTP/1.1\r\nHost: shotlu.usrs0.com\r\n\r\n" it will hit this php file and after that this php file will update a Text file)
<?php
$var1 = $_GET['apples'];
$var2 = $_GET['oranges'];
$fileContent = "You have ".$var1." apples, and ".$var2." oranges.\n";
$fileStatus = file_put_contents('myFile.txt',$fileContent,FILE_APPEND);
if($fileStatus != false)
{
echo "success: data written to file";
}
else
{
echo "FAIL: could not write to file";
}
?>