PHPackages                             donutdan4114/box-view-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. donutdan4114/box-view-api

AbandonedArchivedLibrary[API Development](/categories/api)

donutdan4114/box-view-api
=========================

PHP SDK for the Box View API.

1.0.x-dev(10y ago)144.9k12[6 issues](https://github.com/donutdan4114/box-view-api/issues)MITPHPPHP &gt;=5.3

Since Dec 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/donutdan4114/box-view-api)[ Packagist](https://packagist.org/packages/donutdan4114/box-view-api)[ Docs](https://github.com/donutdan4114/box-view-api)[ RSS](/packages/donutdan4114-box-view-api/feed)WikiDiscussions 1.0 Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

Box View PHP SDK
================

[](#box-view-php-sdk)

**NOTE:** No longer supported. Check out the official [Box View PHP SDK](https://github.com/crocodoc/php-box-view).

*Created by [Daniel Pepin](http://danieljpepin.com) @ [CommonPlaces, Inc](http://commonplaces.com)*
*Sponsored by [LawJacked](http://www.jurify.com)*

---

Documentation
-------------

[](#documentation)

For general API documentaion, please review the [Box View API Documentation](https://developers.box.com/view).

To get started, Include the required classes:

```
require 'lib/box-view-api.php';
require 'lib/box-view-document.php';
```

Intializing the API class:

```
$api_key = 'YOUR_API_KEY';
$box = new Box_View_API($api_key);
```

Creating a document to upload:

```
$doc = new Box_View_Document();
$doc->name = 'My Awesome Document';
$doc->file_url = 'http://my-public-url';
$doc->thumbnails = '128×128,256×256'; // Comma-separated list of thumbnail dimensions of the format {width}x{height} e.g. 128×128,256×256
$doc->non_svg = false; // boolean (default=false)
```

Uploading a document to the API:

```
$box->upload($doc);
```

You can also upload local files through the API:

```
$doc = new Box_View_Document(array(
  'name' => 'My Local File',
  'file_path' => '/path/to/file/CV_Template1.doc',
));
$box->upload($doc);
```

Uploading an array of documents to the API:

```
// Create array of Box_View_Document objects.
$docs[] = new Box_View_Document(array('file_url' => 'http://foo.bar/why-cats-purrrr.pdf'));
$docs[] = new Box_View_Document(array('file_url' => 'http://foo.bar/10-ways-to-love-your-cat.docx'));
$docs[] = new Box_View_Document(array('file_url' => 'http://foo.bar/funny-cat-links.xlsx'));

// Wrap API calls in try/catch.
try
{
  $box->uploadMultiple($docs);
}
catch(Exception $e)
{
  log('error', $e->getMessage());
}
```

After some time, the document will be processed and can be viewed:

```
$box->view($doc);
echo $doc->session->url; // Links to the HTML5 document.
```

Embed the document in an iframe.

```
