So like most people who start out here i’m having some issues.
I’m basically looking to issue a $_POST request to a page on my web server. When i’m posting if i do a full dump on the server end ( print_r($_POST) ) I’m getting a response of 1?
I can do a GET request without anyone issues. Can anyone take a look and see where i’m going wrong?
In the meantime i’m going to now have a play to see if I can save variables which last over a reboot, and read the HTTP response to the Photon.
Can you make the same request to the server using the command line tool curl? If so, you can add -v -v to get verbose output from curl and see the request.
Most likely the server wants to see more fields such as Accept: */* or a different content type such as application/x-www-form-urlencoded instead of text.
A way to debug the actual POST request is the use the service requestb.in where you can setup a temporary spot to post to and see the results in your web browser.
curl is available for every platform (Win/Mac/Linux/iOS/Android) and you should get it for sure. It's a great tool.
For the requestb.in: Port 443 is a SSL port like you would use for HTTPS, not plain HTTP. You don't have a SSL client so posting there isn't going to work. Try posting to port 80 instead. I bet that works.
For your actual server: if you want to pass things like var1=data1 you should use URL encoding as the content type and avoid sending funny characters (or actually URL encode them). Try sending a simple string like "var1=data1" and force the content length to be correct (10 in this case).
So good news is it looks like the blank line is done the job.
When trying to connect with the curl method I do get: curl: (5) Could not resolve proxy: POST
.
With that the job is a good one. Thank you so much for your assistance. I just need to figure out how to read the response from the server now. I’m happy to give this a go.