Jump to content




http.post... Question


  • You cannot reply to this topic
6 replies to this topic

#1 Goof

  • Members
  • 751 posts

Posted 16 May 2013 - 08:49 AM

Hello!

im having a quite big issue, with posting two or more variables to a website, but i dont think im posting correct:

http.post("http://advlock.webuda.com/lockP.php?", "key=" .. key .. ", licensekey=" .. computer[pos].key)

does anyone know if thats a valid posting method? (if not then please tell me what i need to add/remove)
and btw, the two variables "key" and "computer[pos].key" is some variables from an input / table.

Thanks in Advance

#2 SadKingBilly

  • Members
  • 160 posts

Posted 16 May 2013 - 08:55 AM

http.post("http://advlock.webuda.com/lockP.php?", "key=" .. textutils.urlEncode(key) .. "&licensekey=" .. textutils.urlEncode(computer[pos].key))
I've never worked with the HTTP API, and I don't know the details of what you're doing, but try that.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 16 May 2013 - 09:10 AM

yes, its correct, but you dont need that ? after it, thats for the GET parimeter

#4 Goof

  • Members
  • 751 posts

Posted 16 May 2013 - 10:05 AM

the textutils.encode is ONLY for the http.get. but thanks. will try the code :D

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 16 May 2013 - 11:11 AM

You were missing an & which SadKingBilly got correct

#6 SadKingBilly

  • Members
  • 160 posts

Posted 16 May 2013 - 11:19 AM

View PostMikk809h, on 16 May 2013 - 10:05 AM, said:

the textutils.encode is ONLY for the http.get. but thanks. will try the code :D
The pastebin program disagrees with you:
local response = http.post("http://pastebin.com/api/api_post.php", "api_option=paste&".."api_dev_key="..key.."&".."api_paste_format=lua&".."api_paste_name="..textutils.urlEncode(sName).."&".."api_paste_code="..textutils.urlEncode(sText))
You may have to to use urlEncode(), depending on the content of your variables. Whether it's a POST or GET, a random ampersand can still confuse the script and quotation marks can cause syntax errors if not escaped (by urlEncode()). The only thing strictly incorrect about my post was that I kept the "?" in there. Granted, you had it there, so I still can't be sure whether you're looking to do a POST or GET.

#7 Goof

  • Members
  • 751 posts

Posted 16 May 2013 - 02:58 PM

Hmm. but. the code is working fine, but the webpage is erroring out... hmm whats wrong.. i know its a bit away from lua, but if someone knows how to fix, it then please tell me :D/>

Error:

Parse error: syntax error, unexpected T_STRING in /home/a1652713/public_html/lockP.php on line 4


Spoiler

Thanks :D/>





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users