public function ShowFiles($folder_id) { $box_items = parent::get_folder_items($folder_id); $items = array(); if (isset($box_items['entries'])) { if (is_array($box_items['entries'])) { foreach ($box_items['entries'] as $entries) { if ($this->Get_type($entries['type']) == 0) { array_push($items, array("name" => $entries['name'], "id" => $entries['id'], "type" => $entries['type'], "link" => null, "url" => null, "size" => null, "download_count" => null)); } else { if ($this->Get_type($entries['type']) == 1) { $file_item = parent::get_file_details($entries['id']); $shared = $file_item['shared_link']; $url = null; $link = null; $download = null; if (count($shared) != 0 || $shared != null) { $url = $shared['url']; $link = $shared['download_url']; $download = $shared['download_count']; } array_push($items, array("name" => $file_item['name'], "id" => $file_item['id'], "type" => $file_item['type'], "link" => $link, "url" => $url, "size" => round($file_item['size'] / 1024 / 1024, 2) . " Mb", "download_count" => $download)); } } } } } return $items; }
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(); } } // User details $box->get_user(); // Get folder details $box->get_folder_details('FOLDER ID'); // Get folder items list $box->get_folder_items('FOLDER ID'); // All folders in particular folder $box->get_folders('FOLDER ID'); // All Files in a particular folder $box->get_files('FOLDER ID'); // All Web links in a particular folder $box->get_links('FOLDER ID'); // Get folder collaborators list $box->get_folder_collaborators('FOLDER ID'); // Create folder $box->create_folder('FOLDER NAME', 'PARENT FOLDER ID'); // Update folder details $details['name'] = 'NEW FOLDER NAME'; $box->update_folder('FOLDER ID', $details); // Share folder $params['shared_link']['access'] = 'ACCESS TYPE';
function __construct() { 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(); } } // User details $box->get_user(); // Get folder details $box->get_folder_details('FOLDER ID'); // Get folder items list $box->get_folder_items('FOLDER ID'); // All folders in particular folder $box->get_folders('FOLDER ID'); // All Files in a particular folder $box->get_files('FOLDER ID'); // All Web links in a particular folder $box->get_links('FOLDER ID'); // Get folder collaborators list $box->get_folder_collaborators('FOLDER ID'); // Create folder $box->create_folder('FOLDER NAME', 'PARENT FOLDER ID'); // Update folder details $details['name'] = 'NEW FOLDER NAME'; $box->update_folder('FOLDER ID', $details); // Share folder $params['shared_link']['access'] = 'ACCESS TYPE'; //open|company|collaborators print_r($box->share_folder('FOLDER ID', $params)); // Delete folder $opts['recursive'] = 'true'; $box->delete_folder('FOLDER ID', $opts); // Get file details $box->get_file_details('FILE ID'); // Upload file $box->put_file('RELATIVE FILE URL', '0'); // Update file details $details['name'] = 'NEW FILE NAME'; $details['description'] = 'NEW DESCRIPTION FOR THE FILE'; $box->update_file('FILE ID', $details); // Share file $params['shared_link']['access'] = 'ACCESS TYPE'; //open|company|collaborators print_r($box->share_file('File ID', $params)); // Delete file $box->delete_file('FILE ID'); if (isset($box->error)) { echo $box->error . "\n"; } }