-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathexample.php
More file actions
81 lines (60 loc) · 1.9 KB
/
example.php
File metadata and controls
81 lines (60 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?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();
}
}
// 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', 'FILE NAME', 'FOLDER ID');
// 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');
// Download file
$box->download_file('FILE ID', 'DESTINATION');
if (isset($box->error)){
echo $box->error . "\n";
}
?>