2017-03-22 26 views
0

我在Dropbox帐户的文件夹中添加了一些文件。除了每个文档之外,我还放置了一个下载按钮来显示Dropbox文件夹中的文件。如何从Dropbox文件夹预览文件

我已经尝试使用共享链接与Dropbox API中的设置,但它只能使用一次。如果我第二次点击它说共享链接已经存在。

是否有任何其他方式预览文件从Dropbox文件夹到我们的页面?

下面是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); 

回答

相关问题