Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL Encoding a variable for a web service call on Roku

I need to URL encode a variable that is being passed into a web service.

testcategory = "Action and Adventure"
jsonRequest = CreateObject("roUrlTransfer")
jsonRequest.SetURL("http://myurl.com/?method=getRokuCategorizedSeriesListing&category=" + testcategory)

I need to have whatever the value be for "testcategory" to be url encoded to be passed it to this web service call. In this example I would need "Action and Adventure" to be "Action%20and%20Adventure"

Is there a Brightscript function to accomplish this?

Any help would be very appreciated.

Thank you!

like image 409
Josh Scott Avatar asked Dec 06 '25 23:12

Josh Scott


1 Answers

Place this function in one of your brightscript file

Function HttpEncode(str As String) As String
    o = CreateObject("roUrlTransfer")
    return o.Escape(str)
End Function

and then you can use the function HttpEncode as

jsonRequest.SetURL("http://myurl.com/?method=getRokuCategorizedSeriesListing&category=" + HttpEncode(testcategory) )
like image 154
Paras Nath Chaudhary Avatar answered Dec 11 '25 13:12

Paras Nath Chaudhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!