Dropbox API Creating a shared link for a file using curl in PHP


Example

<?php

$parameters = array('path' => '/test.txt');

$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/sharing/create_shared_link_with_settings');
curl_setopt_array($ch, $curlOptions);

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

curl_close($ch);

?>

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