Jump to content




Using http.post to post a form on a php web page


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

#1 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 08 February 2013 - 09:50 AM

Hey, I'm trying to do what Cranium did with his smartpost:
local response = http.post(
    "http://pastebin.com/api/api_login.php",
    "api_dev_key="..key.."&"..
    "api_user_name="..textutils.urlEncode(user).."&"..  
    "api_user_password="..textutils.urlEncode(pass)  
)

I'm trying to figure out how to use it for a form for my new CC YouTube program.
This is the website I'll be posting to: http://cc-youtube.ho...om/add-info.php

Of course, if I can, I'll remove the simple math question ,_,

But is this possible?

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 08 February 2013 - 10:18 AM

View PostremiX, on 08 February 2013 - 09:50 AM, said:

Hey, I'm trying to do what Cranium did with his smartpost:
local response = http.post(
	"http://pastebin.com/api/api_login.php",
	"api_dev_key="..key.."&"..
	"api_user_name="..textutils.urlEncode(user).."&"..  
	"api_user_password="..textutils.urlEncode(pass)  
)

I'm trying to figure out how to use it for a form for my new CC YouTube program.
This is the website I'll be posting to:

Of course, if I can, I'll remove the simple math question ,_,

But is this possible?
Yes, it's perfectly possible. But which site is it exactly, I don't see it there? (copy paste mistake? :P)

#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 08 February 2013 - 10:23 AM

Hmm, well that's quite dumb of me xD

Added link in first post

#4 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 08 February 2013 - 10:52 AM

I looked into it and I came up with this:
local username = "remiX"
local title = "video title"
local url = "http://pastebin.com/ABCDEF"
local description = "video description"
local answer = "42"  -- the answer to the user question

local params = string.format("username=%s&video_title=%s&video_url=%s&description=%s&user_answer=%s&answer=%s&contact_submitted=send", username, title, textutils.urlEncode(url), description, answer, answer)
local res = http.post("http://cc-youtube.hostei.com/add-info.php", params)  -- or use http.request if you want to know the success state

I can't test this yet, I have little time. But aside for an eventual typo or stupid syntax mistake, I'm quite sure that this will work.

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 08 February 2013 - 06:20 PM

Wow, thanks. It worked :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users