Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
greengiant83
Visitor

How to post form data to URL

I have a few variable that I need to post to a remote server and get the response back from. Basically, I want to get the results back a server as if I had hit the submit button in the browser on a simple page like this:

<html>
<body>
<form action="http://www.gaiamtv-qa.gaiam.com/api/s/login" method="post">
MyParameter1: <input name="MyParameter1" value="foo" /><br />
MyParameter2: <input name="MyParameter2" value="bar" /><br />

<input type="submit" />
</form>
</body>
</html>
0 Kudos
4 REPLIES 4
RokuChris
Roku Employee
Roku Employee

Re: How to post form data to URL

Take a look at the http_post_from_string_with_timeout() function in the urlUtils.brs file in the videoplayer example.

Also the AsyncPostFromString() function of roURLTransfer: http://sdkdocs.roku.com/display/RokuSDK ... ingrequest
0 Kudos
greengiant83
Visitor

Re: How to post form data to URL

How do I format the form fields into a single string?
0 Kudos
RokuJoel
Binge Watcher

Re: How to post form data to URL

url="http://www.gaiamtv-qa.gaiam.com/api/s/login?MyParameter1=foo&myparameter2=bar"

or

url="http://www.gaiamtv-qa.gaiam.com/aip/s/login?myparameter1="+myparameter1+"&myparameter2="+myparameter2

xfer=createobject("roURLTransfer")
xfer.seturl(url)
asyncpostfromstring("")


Of course you would need to set up a message port and wait loop to handle the async event results, and you would probably want to xfer.urlencode(parameter) before concatenating the variables into the post string.

- Joel
0 Kudos
mushiidoger
Visitor

Re: How to post form data to URL

hello
i want to send username and password in post form
i not found any right way to do it kindly help me.
i have username in one variable and password in other variable
and i have url so how i send request to the server in post form