Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello,
Am trying to download file from dropbox using dropbox api-PHP.
I have a sharelink generated using dropbox api
$dropbox->postToAPI
is "https://www.dropbox.com/s/bs69w68dwoiiu2q/img0007cade2gtw.jpg?raw=1".
Am not able to download file from dropbox using
$dropbox->download(url);
Note that Dropbox does not have an officially supported SDK in PHP, so if you have any SDK specific questions, you will need to ask the developer who authored the SDK.
It appears that you might be using the "kunalvarma05/dropbox-php-sdk". If that is the case, I suggest reading their wiki page on Uploading and Downloading files (https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Upload-and-Download-Files) as it has some helpful examples.
Looking at your example, there are two ways you can possibly solve your problem.
1) Because you have already created a shared link with the API, you do not need to use the "download()" method. The link you have posted above can be downloaded with any PHP library or function for accessing a URL on the web. The file_get_contents() (http://php.net/manual/en/function.file-get-contents.php) method appears to be a very commonly used approach for downloading a file with a url.
2) Downloading a file does not require creating a shared link first. If you know the path of the file you wish to download, you can use the path of the file within Dropbox to download directly. Assuming you are using the "kunalvarma05/dropbox-php-sdk", the usage would be:
$dropbox->download(<path of file in dropbox>, <path to save locally>)
A third possible solution would be to use the sharing/get_shared_link_file API method. This takes a "url" parameter that would match the shared link URL in your original post, and will return the raw bytes of the file referenced by the shared link. This approach would be similar to my suggestion #1 in my previous reply.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!