120 posts
Posted 08 February 2013 - 02:36 PM
how do you format a post for the http api?
what i'm trying to do is send some text to a php page
2217 posts
Location
3232235883
Posted 08 February 2013 - 02:49 PM
normally i dont use post, i usually use get because you can debug it through a standard browser
http://www.computerc.../HTTP_%28API%29
286 posts
Location
Bonn Germany
Posted 08 February 2013 - 02:59 PM
normally i dont use post, i usually use get because you can debug it through a standard browser
http://www.computerc.../HTTP_%28API%29
To debug POST requests you can use Postman for Google Chrome. (
https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?utm_source=chrome-ntp-icon)
However sometimes you're forced to use POST parameters.
Back to topic:
Use this function
http://computercraft.info/wiki/Http.post and layout the content of the postdata like so: "key=value&key2=value2" …
404 posts
Location
St. Petersburg
Posted 08 February 2013 - 03:06 PM
if not http.post("www.websiteurl.com/script.php?v1="..textutils.urlEncode(value1).."&v2="..textutils.urlEncode(value2)) then
-- error code
end
or http.get. or http.request. still sends the data
just putting the pieces of what was already said together
120 posts
Posted 08 February 2013 - 05:20 PM
for what i'm doing i think i'll use xuma's method
though i may have to use tesla's later on
404 posts
Location
St. Petersburg
Posted 08 February 2013 - 06:15 PM
something to consider is that HTTP documentation prefers the GET verb over the POST verb, so if you're only sending args in a URL, use http.get
their explanation is that GET is "safer" than POST
EDIT: HTTP documentation meaning IRL HTTP, not the API
2088 posts
Location
South Africa
Posted 08 February 2013 - 07:14 PM
I asked this question yesterday xD
Clicky!