Using an ESP8266 and using the following AT commands I can successfully get the webpage:
AT+CIPSTART="TCP","www.somewebsite.com",80
AT+CIPSEND=80
> GET http://www.somewebsite.com HTTP/1.0
<I get a bunch of HTML here>
So far so good. Now I have a php page on my website that takes a few parameters and updates a table in a database accordingly. So when I type:
http ://www.mywebsite.com/mypage.php?arg1=one&arg2=two
It successfully updates the table. Now when I try to use ESP8266 to do the same I get a DNS fail:
AT+CIPSTART="TCP","http://www.mywebsite.com/mypage.php?arg1=one&arg2=two",80
<get DNS fail here>
Even if I try the php page without the arguments I get DNS fail:
AT+CIPSTART="TCP","http://www.mywebsite.com/mypage.php",80
<get DNS fail here>
Does anyone know what's going on? Could it be that the php page is not on port 80? And if that's the case, how do I find out what port it's on?
By the way, if I do the same with an html page on my website it works just fine.
EDIT: When I try this:
AT+CIPSTART="TCP","www.mywebsite.com",80
> GET /mypage.php?arg1=one,arg2=two
I get this output:
Error 404 - Not Found
And when I try:
AT+CIPSTART="TCP","www.mywebsite.com",80
> GET http://www.mywebsite.com/mypage.php?arg1=one,arg2=two
I get the html code of www.mywebsite.com/index.html and not the php page.
I'm also not sure what the "HTTP/1.0" in the GET command does?
You don't put the URL on the AT+CIPSTART
line, that just wants the name of the server. The rest of the URL goes after GET
. Also, if your server does virtual hosting, you need to send a Host:
header to tell it which server name to use.
AT+CIPSTART="TCP","www.mywebsite.com",80
> GET /mypage.php?arg1=one&arg2=two HTTP/1.1
> Host: www.mywebsite.com