forked from donutdan4114/box-view-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
46 lines (34 loc) · 868 Bytes
/
example.php
File metadata and controls
46 lines (34 loc) · 868 Bytes
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
<?php
require 'lib/box-view-api.php';
require 'lib/box-view-document.php';
//
// Manipulate documents using the API.
//
$api_key = 'YOUR_API_KEY';
$box = new Box_View_API($api_key);
// Create new document we want to upload.
$doc = new Box_View_Document(array(
'name' => 'test document',
'file_url' => 'PATH_TO_FILE',
));
// Upload the new document.
$box->upload($doc);
// Change name and update document.
$doc->name = 'new test document';
$box->update($doc);
// Delete the document.
$box->delete($doc);
// List all documents for this app.
$docs = $box->load();
var_dump($docs);
//
// View Documents using the API.
//
$api_key = 'YOUR_API_KEY';
$box = new Box_View_API($api_key);
$doc = new Box_View_Document();
$doc->id = 'DOCUMENT_ID';
$box->view($doc);
// Open file in iframe.
$html = '<iframe src="' . $doc->session->url . '"></iframe>';
echo $html;