You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
steve_lae0901
7 years agoHelpful | Level 6
error using PHP file_get_contents to call list_folder api
any examples available using the PHP file_get_contents function to call the files/list_folder api?
( I am able to use curl from PHP to call the dropbox apis. But my code fails on one PHP server but works on another. Would like to see if file_get_contents will work. )
Here is my code. There error I am getting is "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request "
function listFolder( $token ) { $text = "{\"path\": \"\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false,\"include_mounted_folders\": true}" ; echo $text . '<br>' ; $postdata = http_build_query( array( 'data' => $text)) ; $opts = array( 'http' => array( 'method' => 'POST', 'header' => array('Authorization: Bearer ' . $token, 'Content-Type: application/json'), 'content' => $postdata), 'ssl' => array( "verify_peer"=>false, "verify_peer_name"=>false) ); $context = stream_context_create($opts); $result = file_get_contents('https://api.dropboxapi.com/2/files/list_folder', false, $context); }
I don't believe we have an example for using file_get_contents.
In any case, when you get an error from the API, such as a 400 response, the best first step is to check the response body, which should contain a more useful error.
Anyway, it looks like you have a newer thread, so I'll follow up there:
https://www.dropboxforum.com/t5/API-support/PHP-file-download-returns-page-not-found/m-p/264177#M15462
- Greg-DBDropbox Staff
I don't believe we have an example for using file_get_contents.
In any case, when you get an error from the API, such as a 400 response, the best first step is to check the response body, which should contain a more useful error.
Anyway, it looks like you have a newer thread, so I'll follow up there:
https://www.dropboxforum.com/t5/API-support/PHP-file-download-returns-page-not-found/m-p/264177#M15462
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 10 hours agoIf 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 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!