Skydrive Direct Download Link (Hotlink)

[Edit 17/7/2011: I changed the way the script work, to make the links a lot simpler. Basically, now you just need the id of the folder.]

I’ve been transfering my files to SkyDrive, as my old file host, Fileden, didn’t quite fulfil my needs anymore. What I want in a file host is:

  • Lots of space
  • Large file size allowance
  • Direct file links
  • Large bandwidth cap
Fileden was ok, in the sense that it allowed direct file links (something very few file hosts do), but the space restrictions – 1GB for the free accounts – had become a problem, and the downloads speeds weren’t anything to write home about. SkyDrive on the other hand has a generous 25GB allowance, unlimited bandwidth and a file size limit of 100MB which is acceptable although I’d prefer slightly larger – but it’s free, so I’m not going to complain too much about that.
The only issue is that you don’t have direct file links by default, and although you can find the link on the page, if you look in the source, the links change very frequently, so even if you find the link once, the next day it won’t work.
Basically you need something that updates the link along with the actual link.
After a bit of research on the internet I found some solutions such as this, this or this, but none that quite seemed to fit my needs and the also all seemed to be a bit OTT (and ok – I also found it interesting to see if I could figure out how to do it on my own) so I delved into the, for me, new and exciting world of php and
using a mix of php and regular expressions I came up with a solution. 
Microsoft does not make it easy, hiding the actual download link in a bunch of javascript, and hotlinking to the files is probably a violation of the terms, so take this as a proof of concept.

Download the script from here. The php files serves as a redirect to the current live link to the file. Here is how to use it:

Place the unpacked .php file anywhere on your server.

Open the folder containing the file you want to link to. Make sure the folder is publicly shared:

Now you need the id of the folder. Open the folder where your file is located and check the URL in the address bar. What you need is id that contains ‘%21’ followed by 3 digits, for example:
https://skydrive.live.com/?cid=9e160d622255cccd&sc=documents&id=9E160D622255CCCD%21160

Now you need the link to the skydrivedl.php file you placed on your server, e.g. ‘http://example.com/skydrivedl.php’. To this you add ‘?id=’ and the id from above, for example:
http://example.com/skydrivedl.php?id=9E160D622255CCCD%21160‘.

Next, get the full name of the file you want to download (including extension – you should encode the file name as well if there are any non-letters in it):

Add ‘&fil=’ and the full name of the file to the above link:
http://example.com/skydrivedl.php?id=9E160D622255CCCD%21160&fil=test.rar‘.

Put that in a link. Now, when somebody clicks on that link, the php file will locate that actual file link and start the download.

Here’s a working example:

<a href=”http://corpora.heliohost.org/skydrivedl/skydrivedl.php?id=9E160D622255CCCD%21160&fil=Test.rar“>test</a>

And here it is as a proper link: test

[Edit:] Here is a form you can use to easily create a test link (Please note that this is only for testing. I am using a free host and cannot handle very many queries. If you plan to use this method you should download the php script here and set it up on your own server).

Finally, I’ll just note that I’m using this as a separate file to start downloads. It would be quite easy to modify the script and incorporate it directly in a page, so whenever someone loads the pages, they will get the live links to the files (unless they keep the page open for a really long time :-)).
[Edit: here is a guide on how to embed SkyDrive direct links]

13 responses to “Skydrive Direct Download Link (Hotlink)

  1. Just thought you should know if you take that pic, right click and view original it will give you the link to the pic without having to login to Skydrive. This may be a new feature, but wanted to comment since your post helped me to research further.

    • Hi, thanks for pointing that out, I’ve tried getting the direct link for an image as you suggest and at least for the last 3 days it’s been working fine.
      I honestly don’t know if that has always been the case for images, but for other types of files Skydrive used to change the direct link about once a day (hence all the annoying work-arounds).

  2. This script is great and it worked for me. Just one problem though, when I install the script on my own server (tried 3 different providers) and it won’t work, but when I use the heliohost’s link with my id, then it works… Please help.

    • After chatting with John, it seems that there was a problem with the function stream_get_contents() which is not supported by all versions of PHP. I’ve switched to using file_get_contents() instead which should work for all versions (at least it solved John’s problems).

  3. OHHH!!!

    TANKS!, Arigato! Valeu!, Obrigado! 🙂

  4. The script does not work with a file in the subdirectory

  5. HI, Script don’t work. Even your demo also. Please…,

  6. Hi, DO you make another script for us., Thanks in advance.

  7. Hey guys I just built a new script. It’s currently in beta, but seems to be working just fine. After I do a little more testing, and style the homepage, I will release the source. Check it out: http://onedrive.us.to/

Leave a comment