Jump to content




http api post


6 replies to this topic

#1 etopsirhc

  • Members
  • 122 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

#2 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

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

#3 xuma202

  • Members
  • 288 posts
  • LocationBonn Germany

Posted 08 February 2013 - 02:59 PM

View PostPixelToast, 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

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 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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

#5 etopsirhc

  • Members
  • 122 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

#6 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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

#7 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 08 February 2013 - 07:14 PM

I asked this question yesterday xD

Clicky!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users