ESP8266 Developer Zone The Official ESP8266 Forum 2016-07-04T18:36:19+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2385 2016-07-04T18:36:19+08:00 2016-07-04T18:36:19+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2385&p=7717#p7717 <![CDATA[Re: [SOLVED] HTTP GET Request - How?]]>
Currently this is my definition:

Code:

#define pheadbuffer "GET / HTTP/1.1\r\nUser-Agent: curl/7.37.0\r\nHost: %s\r\nAccept: */*\r\n\r\n"
#define NET_DOMAIN "http://www.mywebsite.org/myPHPFunction.php?myValue=5"


At least i got something back from the server:

Code:

<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_auth_passthrough/2.1 mod_wsgi/3.3 Python/2.7.1 Server at http://www.mywebsite.org/myPHPFunction.php?myValue=5 Port 80</address>
</body></html>


Edit: What i also don't understand is, why i have to create an array with the hardcoded IP:

Code:

const char esp_tcp_server_ip[4] = {X, X, X, X};


if the IP comes from the DNS:

Code:

espconn_gethostbyname(&user_tcp_conn,NET_DOMAIN,&tcp_server_ip,user_dns_found);
os_memcpy(user_tcp_conn.proto.tcp->remote_ip, esp_tcp_server_ip, 4);


If i don't type the IP of the server in that array i don't get any message back, instead i get an

reconnect callback, error code -11
even though i get the message "user_dns_found [correct IP of the server]".

EDIT:

Okay, now this works:

Code:

#define pheadbuffer "GET /myPHPFunction.php?myValue=5 / HTTP/1.1\r\nUser-Agent: curl/7.37.0\r\nHost: %s\r\nAccept: */*\r\n\r\n"

Finally !! :D

Statistics: Posted by Stational — Mon Jul 04, 2016 6:36 pm


]]>
2016-07-04T12:58:13+08:00 2016-07-04T12:58:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2385&p=7704#p7704 <![CDATA[Re: HTTP GET Request - How?]]>
You will find almost everything in the examples, the AT command firmware code on Github/Espressif and the Code Snippets at
http://www.espressif.com/en/products/hardware/esp8266ex/resources

If you are familiar with the TCP/IP, you should be able to get the code running.
NOTE:
1. Use espconn_send() instead of espconn_sent(), which is discontinued.
2. Use GET request to access small pages first when you are testing your code, such as

Code:

www.google.com/thispagedoesnotexist

That reduces possibility of memory overflow issues as well.

Hope it helps!

Statistics: Posted by Guest — Mon Jul 04, 2016 12:58 pm


]]>
2016-07-03T23:27:32+08:00 2016-07-03T23:27:32+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2385&p=7686#p7686 <![CDATA[[SOLVED] HTTP GET Request - How?]]>
i would like to know how i can send HTTP Get requests to a website. Sadly, the API Guide doesn't help :(

Could you give me a little code snippet about how this can be done? On the web i only found code for NodeMCU and for arduino but no SDK-specific code.

Help is very much appreciated :)

Statistics: Posted by Stational — Sun Jul 03, 2016 11:27 pm


]]>