【问题标题】:Box.com shared link on folderBox.com 文件夹上的共享链接
【发布时间】:2014-05-19 18:41:20
【问题描述】:

我正在为 box.com 使用这个 php 类 https://github.com/golchha21/BoxPHPAPI

我已经做了自己的功能来共享这样的文件夹

public function share_folder($folder_id) {
    $url = $this->build_url("/folders/".$folder_id);
    $params = array('shared_link' => array('access' => 'open', 'permissions' =>
        array('can_download' => 'true', 'can_preview' => 'true')));
    return json_decode($this->post($url, json_encode($params)), true);
}

我和这篇文章有同样的问题。 Access denied error message when trying to create a shared link to a folder in Box

有人对此有解决办法或知道为什么会这样吗?

更新

我想通了:

    public function share_folder($folder_id) {
                $url = $this->build_url("/folders/".$folder_id);
                $params = array('shared_link' => array('access' => 'open', 'permissions' =>
array('can_download' => true, 'can_preview' => true)));
                return json_decode($this->put($url, $params), true);

我必须更改它以放置和取下 json_encode

希望这对其他人有帮助

【问题讨论】:

    标签: php permissions box-api shared-directory


    【解决方案1】:

    API 现已更新为共享功能。

    <?php
        include('library/BoxAPI.class.php');
    
        $client_id      = 'CLIENT ID';
        $client_secret  = 'CLIENT SECRET';
        $redirect_uri   = 'REDIRECT URL';
    
        $box = new Box_API($client_id, $client_secret, $redirect_uri);
    
        if(!$box->load_token()){
            if(isset($_GET['code'])){
                $token = $box->get_token($_GET['code'], true);
                if($box->write_token($token, 'file')){
                    $box->load_token();
                }
            } else {
                $box->get_code();
            }
        }
    
        // Share folder
        $params['shared_link']['access'] = 'ACCESS TYPE'; //open|company|collaborators
        print_r($box->share_folder('FOLDER ID', $params));
    
        // Share file
        $params['shared_link']['access'] = 'ACCESS TYPE'; //open|company|collaborators
        print_r($box->share_file('File ID', $params);
    ?>
    

    看看here 下载:BoxPHPAPI

    【讨论】:

      猜你喜欢
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 2023-03-08
      • 2013-09-12
      • 2016-10-09
      • 2022-06-30
      相关资源
      最近更新 更多