Forum Discussion

btpoole's avatar
btpoole
Channel Surfer
12 years ago

roUrlTransfer ??

Need some help. I am working on a private channel. Included in my pkg I have a folder called channel. In the folder I have a single txt file with up to (3) lines text. The text is basic info about about the channel. Once the channel is selected, the server will need to read the text file. I first wanted to copy the txt file from the roku down to the server but have not been successful in doing that so I thought about using a url transfer as follows:
channelinfo=ReadAsciiFile("pkg:/channel/channel.txt")
xfer=CreateObject("roUrlTransfer")
xferport=CreateObject("roMessagePort")
xfer.SetMessagePort(xferport)
channelfile="http://xxx.xxx.xxx.xxx/channelinfo.php?channelfile=" + channelinfo
xfer.SetUrl(channelfile)
response= xfer.AsyncGetToString()
I know the above works, I can use a print statement on the channelinfo and it shows the text in the debug console. The exact url transfer works on another function I am running to get the roku ip, pass it to php, save to server. All that works. For some reason it doesn't work for passing the channelinfo to the server. Any advice or help would be appreciated. If I can just copy the file down from roku that would be great.
Thanks

3 Replies

  • It doesn't look like you're URL encoding the channelInfo anywhere. You can't just tack text onto the end of a URL. You'll need to encode it. Try this:
    channelfile="http://xxx.xxx.xxx.xxx/channelinfo.php?channelfile=" + xfer.UrlEncode(channelinfo)
  • btpoole's avatar
    btpoole
    Channel Surfer
    Thank you The Endless, worked perfect. Odd, I didn't do that when passing the ip address, but then again I didn't read the ip address from a file, it came from the GetIPAddrs function.
    Thanks again
  • An IP address doesn't contain any characters that need to be escaped.

    --Mark