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

escaping spaces in URL

searchText = screen.GetText()
print "search text: "; searchText

m.UrlBase = "http://somewebserver.com/web/"
m.Text = "/sample.php?text="
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()


I'm posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.

My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333

Is there anything I can do in Brightscript to quote searchText to be passed?
0 Kudos
2 REPLIES 2
kbenson
Visitor

Re: escaping spaces in URL

"SolveLLC" wrote:
searchText = screen.GetText()
print "search text: "; searchText

m.UrlBase = "http://somewebserver.com/web/"
m.Text = "/sample.php?text="
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()


I'm posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.

My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333

Is there anything I can do in Brightscript to quote searchText to be passed?


Actaully, the webserver won't, it just looks like it does. Browsers silently escape or urlencode (I always get the terms mixed up) anything in the address bar, so what your webserver actually sees is:
http://somewebserver/web/sample.php?text=1111%203333

If you can check the logs of the webserver, you should be able to confirm or refute this.

If it is the escaping that's the problem, you want is to escape the parameter value, but not the parameter name or URL. Look at the Escape and Unescape methods for the roURLTransfer object.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
SolveLLC
Visitor

Re: escaping spaces in URL

You were right. I use Escape on the parameter and it is working now. Thanks!
0 Kudos