Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Priya M.
9 years agoExplorer | Level 4
Distinction between Oauth 2 and PHP Core API (PHP SDK)
Hi, I'm from Softaculous Ltd and we are now starting to integrate with Dropbox for Backups upload and download. I want to know the difference between your PHP Core API or PHP SDK and OAUTH 2....
- 9 years agoIf you want to use the HTTPS endpoints directly, that's possible using just curl.
Here are some basic examples using curl in PHP:
https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/1354/uploading-a-file-via-curl-in-php#t=201702211923322665017
https://stackoverflow.com/documentation/dropbox-api/410/getting-account-information/1364/getting-space-usage-information-for-the-linked-user-via-curl-in-php#t=201702211923328624075
https://stackoverflow.com/documentation/dropbox-api/412/listing-a-folder/1370/listing-the-root-folder-via-curl-in-php-and-the-curl-extension#t=20170221192336214657
https://stackoverflow.com/documentation/dropbox-api/408/downloading-a-file/20965/downloading-a-file-with-metadata-via-curl-in-php#t=201702211923411507977
https://stackoverflow.com/documentation/dropbox-api/414/getting-a-shared-link-for-a-file-or-folder/24125/creating-a-shared-link-for-a-file-using-curl-in-php#t=201702211923392625782
To get an access token for the end user's account, you need to implement the OAuth app authorization flow. You can find information on how that works here:
https://www.dropbox.com/developers/reference/oauth-guide
The documentation for those endpoints can be found here:
https://www.dropbox.com/developers/documentation/http/documentation#authorization
Greg-DB
Dropbox Community Moderator
9 years agoIt looks like you have an extra redirect in the flow you have implemented. Specifically, you shouldn't be doing step 3. You should only direct the user to /oauth2/authorize once. It appears your app is directing them again a second time, including the extra 'code' parameter the second time.
This blog post may be helpful:
https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/
When encoding URL parameters, you can use whatever standard URL encoding library is available on your platform.
This blog post may be helpful:
https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/
When encoding URL parameters, you can use whatever standard URL encoding library is available on your platform.
Priya M.
9 years agoExplorer | Level 4
Hi,
Now while obtaining an access token, I'm making the curl call to the token endpoint. I cannot make use of the CLI curl command as stated in the example here: https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/
So I'm making a curl call as:
$auth_code = $_GET['code'];
$acc_url = 'https://api.dropboxapi.com/1/oauth2/token';
$post = array('code' => $auth_code,
'grant_type' => 'authorization_code',
'client_id' => '6i45k3fi9a1i9an',
'client_secret' => '<redacted>');
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Get response from the server.
$resp = curl_exec($ch);
echo '<br />Curl Error: '.curl_error($ch);
echo '<br />Curl Response: ';
r_print($resp);
I'm getting the response as:
Error(405):
Something went wrong. Don't worry, your files are still safe and the Dropboxers have been notified. Check out our Help Center and forums for help, or head back to home.
How can I get a detailed error explaining the issue? What wrong am I doing?
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!