Dropbox API Downloading a file Downloading a file with metadata via Requests in PHP


Example

$response = Requests::post("https://content.dropboxapi.com/2/files/download", array(
    'Authorization' => "Bearer <ACCESS_TOKEN>",
    'Dropbox-Api-Arg' => json_encode(array('path' => '/test.txt')),
));

$fileContent = $response->body;
$metadata = json_decode($response->headers['Dropbox-Api-Result'], true);

echo "File " . $metadata["name"] . " has the rev " . $metadata["rev"] . ".\n";

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