We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
TCB
7 years agoExplorer | Level 3
File download using v2 in PHP
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/img0007cade2...
DBX_Robert
Dropbox Staff
7 years agoNote 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>)
DBX_Robert
Dropbox Staff
7 years agoA 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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!