Listing the root folder via curl in PHP and the cURL extension

Download dropbox-api eBook

Example

<?php

$parameters = array('path' => '','include_deleted' => true,'recursive' => true);

$headers = array('Authorization: Bearer <ACCESS_TOKEN>',
                 'Content-Type: application/json');

$curlOptions = array(
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => json_encode($parameters),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_VERBOSE => true
    );

$ch = curl_init('https://api.dropboxapi.com/2/files/list_folder');
curl_setopt_array($ch, $curlOptions);

$response = curl_exec($ch);
echo $response;

curl_close($ch);

?>

Note that the response may contain has_more=true, in which case your app should call back to /files/list_folder/continue to continue getting more entries.

<ACCESS_TOKEN> should be replaced with the OAuth 2 access token.

Stats

Contributors: 2
2017-02-02
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook