8

Is there a way to retrieve a list of the contents of a public Dropbox folder (preferably in PHP)? This is what a URL to a public file in Dropbox looks like:

http://dl.dropbox.com/u/1234567/publikPholder/textytext.txt

One would think that jumping up one level to the directory in the URL...

http://dl.dropbox.com/u/1234567/publikPholder/

...would show all the public files. Nope. Nothing but a 404.

Sam
  • 2,152
  • 6
  • 31
  • 44
  • 1
    Dropbox has an api that may be helpful -> https://www.dropbox.com/developers – Gohn67 Mar 19 '12 at 01:56
  • @Gohn67 Thanks. I've combed through it... nothing (that I could find) for public folders. There is a Python scrip that claims to do what I need, but Python is not an option. http://forums.dropbox.com/topic.php?id=17432 – Sam Mar 19 '12 at 01:59
  • @Sam You probably want to check out [metadata](https://www.dropbox.com/developers/reference/api#metadata) -- see my answer below as well. – chrisn Mar 19 '12 at 02:01
  • can i use the dropbox public url as a source in HTML5: – bouncingHippo Aug 22 '12 at 21:13

3 Answers3

4

Looks like this library is pretty complete (although I haven't used it myself), and is probably as simple as (post-auth):

$info = $dropbox->getMetaData('Public', true);
print_r($info['contents']);
chrisn
  • 2,095
  • 15
  • 20
3

UPDATE: I found a thread on the Dropbox forums where a user posts a link that claims to enable something pretty close to what I'm asking for. Guess what? It works! I don't know where it came from or where it's documented, but if it's helpful to anyone else, here it is (clicking this link will enable it and I don't know if it can be disabled. Proceed with caution):

https://www.dropbox.com/enable_shmodel

The resulting public folder looks like this:

enter image description here

Sam
  • 2,152
  • 6
  • 31
  • 44
  • 1
    Yeah... take a look here for an explanation: https://www.dropbox.com/help/16/en "...all the extra functionality provided by the Public folder is now accessible anywhere in your Dropbox. Now all you need to do to share and preview files and folders in your Dropbox is select Share link via your computers, phones, and tablets..." – Sam Mar 18 '13 at 16:30
  • "Beginning October 3, 2016, you can no longer use shared links to render HTML content in a web browser. If you created a website that directly displays HTML content from your Dropbox, it will no longer render in the browser. The HTML content itself will still remain in your Dropbox and can be shared.", I had a problem with that solution and that little comment described my issue. Hope it'll help anyone else in the future.. – Rotem Oct 14 '16 at 06:52
2

You can use the Dropbox API, specifically the search path. This just returns JSON, which is easy enough to parse.

If you want to just have an index file on your own public Dropbox you can take this approach: http://forums.dropbox.com/topic.php?id=54966.

This generates an index in Python: http://forums.dropbox.com/topic.php?id=17432

mboratko
  • 376
  • 3
  • 16
  • Interesting... here's the URL path: https://api.dropbox.com/1/search// . Using my example above, how would I adjust the URL to point to the public folder? – Sam Mar 19 '12 at 02:01
  • It's a little more complicated than that. Read the Dropbox API link for the full details, or you can use Dropbox API that Chris N linked (that's already PHP, nice). – mboratko Mar 19 '12 at 02:03