lmsilva
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2012
08:32 AM
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
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 3
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2012
09:42 AM
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.
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2012
03:43 PM
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:
and
You might want to try using index.ToStr() instead.
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.
lmsilva
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2012
06:49 PM
Re: Having trouble making an http connection
Ah, that worked! Thanks guys!!!