I'm trying to use libURLDownloadToFile to get one of these files and pull it into the applet, but I only get an empty file (0KB). Is it the case that this command cannot follow the redirects in the file.php? Is there a way to make it do that?
libURLDownloadToFile follow php redirect?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
libURLDownloadToFile follow php redirect?
I'm using Rev/LiveCode to create an applet that is embedded into the pages of the course management system at our school. The CMS is Moodle, which is written in PHP. All links to media files are run through a file.php file, so a link to a file would be https://mymoodlehost.edu/file.php/PathToActualFile
I'm trying to use libURLDownloadToFile to get one of these files and pull it into the applet, but I only get an empty file (0KB). Is it the case that this command cannot follow the redirects in the file.php? Is there a way to make it do that?
I'm trying to use libURLDownloadToFile to get one of these files and pull it into the applet, but I only get an empty file (0KB). Is it the case that this command cannot follow the redirects in the file.php? Is there a way to make it do that?
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10078
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: libURLDownloadToFile follow php redirect?
libURLDownloadToFile is an FTP command, but the protocol in the URL you're using is HTTP.
Have you considered just using "get" and then writing what you get to a file? e.g.:
get url "https://mymoodlehost.edu/file.php/PathToActualFile"
put it into url ("file:"& tMyLocalFile)
Have you considered just using "get" and then writing what you get to a file? e.g.:
get url "https://mymoodlehost.edu/file.php/PathToActualFile"
put it into url ("file:"& tMyLocalFile)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: libURLDownloadToFile follow php redirect?
libURLDownloadToFile also speaks HTTP and HTTPS, according to the dictionary. I was able to use it from another static HTTP address without any problem whatsoever.
I did try what you suggested, and that also failed.
I did try what you suggested, and that also failed.
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10078
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: libURLDownloadToFile follow php redirect?
The URL works well in your browser?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: libURLDownloadToFile follow php redirect?
Yes, it does, as long as I'm logged into the course management system in that browser. The file downloads without a hitch in that case. It's for that reason that i suspect the problem is more in the way Rev is trying to call the file and less to do with permissions of the server or CMS itself.
FWIW, I'm using Rev Enterprise 4.0.0 Build 950. I want to move to LiveCode, but cannot realistically do so until they release the revweb plugins compatible with that version.
Thanks for thinking about this, I very much appreciate the assistance. Please let me know if you have any other ideas on how to work around this.
FWIW, I'm using Rev Enterprise 4.0.0 Build 950. I want to move to LiveCode, but cannot realistically do so until they release the revweb plugins compatible with that version.
Thanks for thinking about this, I very much appreciate the assistance. Please let me know if you have any other ideas on how to work around this.
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10078
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: libURLDownloadToFile follow php redirect?
Sounds like the server is expecting to authenticate the session but is unable to with your script. May require adding cookie support in your script; hard to say without knowing more about how the server and its login work.cborn wrote:Yes, it does, as long as I'm logged into the course management system in that browser. The file downloads without a hitch in that case.
If you have a port sniffer like Little Snitch you can log the transaction when you sign in and get the document from your browser, and that should provide good guidance for what's needed to emulate those browser behaviors in your script.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: libURLDownloadToFile follow php redirect?
Richard,
Thanks for this tip, I managed to get the cookie info into a GET request and got it working!
Thanks for this tip, I managed to get the cookie info into a GET request and got it working!
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10078
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: libURLDownloadToFile follow php redirect?
Excellent! Glad to hear it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn