使用 PHP 中的 curl 為檔案建立共享連結

<?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> 應替換為 OAuth 2 訪問令牌。