how do you format a post for the http api?
what i'm trying to do is send some text to a php page
1
http api post
Started by etopsirhc, Feb 08 2013 02:36 PM
6 replies to this topic
#1
Posted 08 February 2013 - 02:36 PM
#2
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
http://www.computerc.../HTTP_%28API%29
#3
Posted 08 February 2013 - 02:59 PM
PixelToast, on 08 February 2013 - 02:49 PM, said:
normally i dont use post, i usually use get because you can debug it through a standard browser
http://www.computerc.../HTTP_%28API%29
http://www.computerc.../HTTP_%28API%29
To debug POST requests you can use Postman for Google Chrome. (https://chrome.googl...chrome-ntp-icon)
However sometimes you're forced to use POST parameters.
Back to topic:
Use this function http://computercraft.../wiki/Http.post and layout the content of the postdata like so: "key=value&key2=value2" ...
#4
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 endor http.get. or http.request. still sends the data
just putting the pieces of what was already said together
#5
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
though i may have to use tesla's later on
#6
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
their explanation is that GET is "safer" than POST
EDIT: HTTP documentation meaning IRL HTTP, not the API
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users