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: 
lmsilva
Visitor

Having trouble making an http connection

Dear all,

I'm playing around with the sample code in the SDK and I'm trying to capture the "up" key in the custom video player example, sending the event to a php script I have and displaying it in the screen:
'If the <UP> key is pressed, jump out of this context:
else if msg.isRemoteKeyPressed()
index = msg.GetIndex()
print "Remote button pressed: " + index.tostr()
m.help = "Remote button pressed: " + index.tostr()
if index = 2 '<UP>
url = "http://192.168.1.217/myscript.php?keypress=" + index
m.help = m.help + "You pressed up! This is where we would capture your vote! ;o)"
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://192.168.1.217/myscript.php?keypress=" + xfer.Escape(index))
response = xfer.GetToString()
m.help = m.help + response
m.setup()
else if index = 3 '<DOWN> (toggle fullscreen)
...

Any idea why my box hangs when I do this?
I also tried copying the urlUtils.brs from another sample and using:
http = NewHttp("http://192.168.1.217/myscript.php?keypress=" + xfer.Escape(index))
rsp = http.GetToStringWithRetry()

But that also hangs my Roku...

Any thoughts?

p.s. on an unrelated matter, is BrightScript CaseSenSitive?

Thanks,
Luis
0 Kudos
3 REPLIES 3
destruk
Streaming Star

Re: Having trouble making an http connection

What does the debugger say? What happens when you try to pull the page request in a browser? And it's possible that the script is adding an http://, so try removing yours in your string.
0 Kudos
belltown
Roku Guru

Re: Having trouble making an http connection

I see a couple of places where you're using 'index' (an Integer) where a String is expected:

url = "http://192.168.1.217/myscript.php?keypress=" + index

and
xfer.SetURL("http://192.168.1.217/myscript.php?keypress=" + xfer.Escape(index))


You might want to try using index.ToStr() instead.
0 Kudos
lmsilva
Visitor

Re: Having trouble making an http connection

Ah, that worked! Thanks guys!!!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.