Forum Discussion

lmsilva's avatar
lmsilva
Visitor
14 years ago

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

3 Replies

  • destruk's avatar
    destruk
    Streaming Star
    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.
  • 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.