3

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!

4

1 回答 1

3

将此功能放在您的一个brightscript文件中

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

然后你可以使用函数 HttpEncode 作为

jsonRequest.SetURL("http://myurl.com/?method=getRokuCategorizedSeriesListing&category=" + HttpEncode(testcategory) )
于 2014-06-18T11:59:31.253 回答