phpdropbox-php

how to make a Password Protected shared link in Dropbox using php_sdk client


I can upload files from the PHP SDK, It is uploading and also getting the shared link back. But my issue is, how I can make and empty folder with password protected shared link. I am researching on it, but I could not find a good way to do it. Here is waht I researched.

$response = $dropbox->postToAPI("/sharing/create_shared_link_with_settings", ["path" => "/BABERZAMAN/hello-world.txt", "settings" => ['requested_visibility' => 'public']]);

$data = $response->getDecodedBody();
var_dump($data);

This is what I am using and Uploading files.

$db_path = "/".$db_folders."/".$file_renamed;
        $file = $dropbox->upload($dropboxFile, $db_path , ['autorename' => true]);
        $pathToFile = $db_path;
        
        $response = $dropbox->postToAPI("/sharing/create_shared_link", [
            "path" => $pathToFile,
            "short_url" => false,
        ]);
        
        $shared_link = $response->getDecodedBody();
        $db_shared_link = $shared_link["url"];

So for now I have just 2 issues.

  1. Make empty folder
  2. Get that folder's shared link but password Protected For Random Password I can use rand(0000000000,99999999);

I got the issue solved for Creating empty Folder

$MainDirectory = '/BABERTEST';

//Create empty folder
$MakeFolder = $dropbox->createFolder($MainDirectory);
        $response = $dropbox->postToAPI("/sharing/create_shared_link", [
            "path" => $MainDirectory,
        ]);
          
        $shared_link = $response->getDecodedBody();
        
      

        $BackupLink = $shared_link["url"];
        echo $BackupLink;

But the other Part, Sharing Link with Password is still pending. Need help


Solution

  • I got it fixed by myself.

    $response = $dropbox->postToAPI("/sharing/create_shared_link_with_settings", [
            "path" => $MainDirectory, 
            "settings" => ['requested_visibility' => 'password', 'link_password' => '123456']
            ]);