I have added some files into my folder in Dropbox account. Beside of each document I have put a download button to show the files in Dropbox folder.
I have tried with sharelink with settings in Dropbox API, but it works only for one time. If i click it on second time it says sharelink already exists.
Is there any other way to preview the files from Dropbox folder to our page?
Below is the code for sharelink:
$path='/test.txt';
$ch = curl_init();
$url1="https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings";
$post = array(
"path"=> "/".$path,
"settings"=> array(
"requested_visibility"=> "public"
)
);
$link = json_encode($post);
curl_setopt($ch,CURLOPT_URL,$url1);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$link);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
$headers[] = "Authorization: Bearer ".$TOKEN;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response1 = curl_exec($ch);
$sharelink = json_decode($response1,true);