2014-03-28 142 views
0

我使用這個PHP類box.com https://github.com/golchha21/BoxPHPAPIBox.com共享鏈接文件夾

我已經作出了自己的功能共享文件夾這樣

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

希望這有助於別人

回答

0

的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