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: 
squirreltown
Roku Guru

URLTransfer

I have a slideshow. User can select a button "Like This Image" - this gets URLtransfer to download a file to /tmp, but the point is simply accessing the URL, which is a PHP file which sends me email with the name of the image the user clicked on. All this works fine. The problem is it only works with one particular image. It will work repeatedly while on that image. The debugger prints that the proper title/variable is present in the urlTransfer function on all images, but this only works with this particular image, weather its first or 10th in the slideshow. I dont see how the Roku cares which image its on in this case as its getting the proper titles from the variable curr_photo below. Here are the two releveant lines form the code:

UT.SetUrl("http://www.xxx.com/roku/url/thankyou.php?subject=" + curr_photo.GetTitle() + ".roku")
UT.AsyncGetToFile("tmp:/xx"+ curr_photo.GetTitle())


Totally stumped.
Thanks
Kinetics Screensavers
0 Kudos
9 REPLIES 9
destruk
Streaming Star

Re: URLTransfer

What are the titles of some of the photos? Or perhaps it is caching the image so you would need to add a cachebreaker, or delete it from tmp when downloading another image.
0 Kudos
TheEndless
Channel Surfer

Re: URLTransfer

We'd also need to know how curr_photo is getting set. My guess is that it's not getting accurately reset with each new photo.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
squirreltown
Roku Guru

Re: URLTransfer

Hello destruk

The title of the image that works is "Midtown". Its the first one in that particular slideshow. It also appears in another slideshow at a random location. In both cases the email thing goes through. The second title is "Second Avenue". It doesn't work, nor does a couple of others i tried.
Is there something wrong with my /tmp title? It should be making unique names for each as in "xxMidtown", "xxSecondAvenue" etc. I'm under the impression that I"m solving any cache problems that way, No? Does the Roku check for the existence of the file first, and if its there it doesn't send the url request? That would definitely indicate a cache problem

How do I delete the file in tmp/ each time? I would try that since its not needed anyway.

Thanks
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: URLTransfer

theEndless -
I have a print command in the function that does all this, and it is printing the proper title each time. There is a canvas that pops up and says "thank you" for 2 seconds and then the debugger prints the proper title, so i think that means the right value is set for that variable, am I wrong about that?

print curr_photo.GetTitle()


thanks
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: URLTransfer

Ok i just tried starting the app fresh, and the email worked with a different image, but then not with any others, so the problem is it works once and then not again, the image itself is not the problem it seems like cache issues yes?
Kinetics Screensavers
0 Kudos
destruk
Streaming Star

Re: URLTransfer

I agree with TheEndless -
You want to watch it work in the debugger and add some prints.
UT.SetUrl("http://www.xxx.com/roku/url/thankyou.php?subject=" + curr_photo.GetTitle() + ".roku")
print UT.GetURL()
UT.AsyncGetToFile("tmp:/xx"+ curr_photo.GetTitle())


The reason for GetURL is to make sure it is properly encoded to grab the correct image from your server script.
Maybe execute your php script manually in a browser with some echo'd debugging information using the URL that was printed for the retrieval request too.
If it's caching, then you can add a cache breaker using a timestamp on the url request - ie

timestamp=CreateObject("roDateTime")
UT.SetUrl("http://www.xxx.com/roku/url/thankyou.php?subject=" + curr_photo.GetTitle() + ".roku"+"&cache="+timestamp.AsSeconds())
0 Kudos
destruk
Streaming Star

Re: URLTransfer

Alternately, you could retrieve the file as a new name each time in the tmp folder and keep track of the new name in an array, older files will be pushed out of tmp when it fills up.
To learn how to delete a file - look at roFileSystem
0 Kudos
squirreltown
Roku Guru

Re: URLTransfer

Ok thanks both of you. I'll work on it awhile, I'm got it to work with one slideshow but not another, I think I'm confusing the roku somehow with how its written, I'll add some prints and see what happens.
thanks again for weighing in, i know i'll get it eventually.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: URLTransfer

Thanks again to theEndless and destruk, I have solved this. It really wasn't a Roku problem. I was using the image title in the GetURL, and some of the titles had two words, so there was a space in between and thats a no-go in a URL. I switched to sending the filename of the image, where there no spaces and it works every time. Using the print command on GetUrl made it obvious once i tried it on a bunch of pics in a row.
Also did work out deleting the tmp file but it wasn't really the issue, nice to be tidy i guess.
Kinetics Screensavers
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.