Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Level 7

how use GET/Post method in RoUrlTranfer

Hi Friend,

My problem is while creating RoUrlTranfer
i need to post one xml string along with querystring with the method POST and get responce string

How to set Post method in http header

please tell me.....

thanks in advance
0 Kudos
5 Replies
Roku Employee
Roku Employee

Re: how use GET/Post method in RoUrlTranfer

You would probably want to use the asyncpostfromstring() method of roURLTransfer.

- Joel
0 Kudos
Highlighted
Level 7

Re: how use GET/Post method in RoUrlTranfer

Thank Q for reply its working
0 Kudos
Highlighted
Level 7

Re: how use GET/Post method in RoUrlTranfer

Can you share the code snippet ???

Thx
0 Kudos
Highlighted
Roku Employee
Roku Employee

Re: how use GET/Post method in RoUrlTranfer

"Sike1234" wrote:
Can you share the code snippet ???


Take a look at the http_post_from_string_with_timeout() function in the videoplayer sample.
0 Kudos
Highlighted
Level 7

Re: how use GET/Post method in RoUrlTranfer

here the code

Function http_get_to_string_with_retry1() as Object
Pvar=privatevariables()
timeout% = 1500
num_retries% = 5

resHeaders = CreateObject("roAssociativeArray")
resArray = CreateObject("roArray", 5, false)
while num_retries% >

if (m.Http.AsyncPostFromString("Here you can post your string"))
event = wait(timeout%, m.Http.GetPort())
if type(event) = "roUrlEvent"
'print "***";event.GetInt();"***";event.GetResponseCode();"***";event.GetFailureReason();"***";event.GetSourceIdentity()
resArray.push(event.GetString())
resArray.push(event.GetResponseHeadersArray())
exit while
elseif event = invalid
m.Http.AsyncCancel()
REM reset the connection on timeouts
print"m.Http.GetUrl()",m.Http.GetUrl()
m.Http = CreateURLTransferObject(m.Http.GetUrl())
timeout% = 2 * timeout%
else
print "roUrlTransfer::AsyncGetToString(): unknown event"
endif
endif

num_retries% = num_retries% - 1
end while

return resArray[0]
End Function
0 Kudos