Download the PHP package radzserg/php-box-view without Composer
On this page you can find all versions of the php package radzserg/php-box-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-box-view
php-box-view
Introduction
php-box-view is a PHP wrapper for the Box View API. The Box View API lets you upload documents and then generate secure and customized viewing sessions for them. Our API is based on REST principles and generally returns JSON encoded responses, and in PHP are converted to associative arrays unless otherwise noted.
For more information about the Box View API, see the API docs at developers.box.com.
Installation
Requirements
- PHP 5.4 or newer
Install with Composer
We recommend installing php-box-view
using Composer.
If you don't have Composer, you can install it from the command line:
Use Composer to install the latest stable version:
Make sure to add this package to your composer.json file. And if you aren't doing this already, require Composer's autoloader from your project:
Install without Composer
Download the library and put it in your project. You will also need to download and include Guzzle.
From the file you want to include it from, just use the autoload file:
Getting Started
Get an API Key
Create a Box Application to get an API key.
Enter your application name, click the option for Box View
, and click Create Application
.
Then click Configure your application
.
You can find your API key where it says View API Key
.
In the future, if you need to return to this page, go to Box Developers > My Applications and click on any of your Box View apps.
Examples
You can see a number of examples on how to use this library in examples/examples.php
.
These examples are interactive and you can run this file to see php-box-view
in action.
To run these examples, open up examples/examples.php
and change this line to show your API key:
Save the file, make sure the examples/files
directory is writable, and then run examples/examples.php
:
You should see 17 examples run with output in your terminal.
You can inspect the examples/examples.php
code to see each API call being used.
Your Code
To start using php-box-view
in your code, set your API key:
Tests
First make sure you're running Composer and that you've run composer install
.
Run the tests:
Support
Please use GitHub's issue tracker for API library support.
Usage
Fields
All fields are accessed using getters. You can find a list of these fields below in their respective sections.
Errors
Errors are handled by throwing exceptions.
We throw instances of Box\View\BoxViewException
.
Note that any Box View API call can throw an exception.
When making API calls, put them in a try/catch block.
You can see examples/examples.php
to see working code for each method using try/catch blocks.
Document
Fields
Field | Getter |
---|---|
id | $document->id() |
createdAt | $document->createdAt() |
name | $document->name() |
status | $document->status() |
Upload from File
https://developers.box.com/view/#post-documents
To upload a document from a local file, use $boxView->uploadFile()
.
Pass in a file resource, and also an optional associative array of other params.
This function returns a Box\View\Document
object.
The response looks like this:
Upload by URL
https://developers.box.com/view/#post-documents
To upload a document by a URL, use $boxView->uploadUrl()
.
Pass in the URL of the file you want to upload, and also an optional associative array of other params.
This function returns a Box\View\Document
object.
The response looks like this:
Get Document
https://developers.box.com/view/#get-documents-id
To get a document, use $boxView->getDocument()
.
Pass in the ID of the document you want to get.
This function returns a Box\View\Document
object.
The response looks like this:
Find
https://developers.box.com/view/#get-documents
To get a list of documents you've uploaded, use $boxView->findDocuments()
.
Pass an optional associative array of parameters you want to filter by.
This function returns an array of Box\View\Document
objects matching the request.
The response looks like this:
Download
https://developers.box.com/view/#get-documents-id-content
To download a document, use $document->download()
.
This function returns the contents of the downloaded file.
The response is just a giant string representing the data of the file.
Thumbnail
https://developers.box.com/view/#get-documents-id-thumbnail
To download a document, use $document->thumbnail()
.
Pass in the width and height in pixels of the thumbnail you want to download.
This function returns the contents of the downloaded thumbnail.
The response is just a giant string representing the data of the file.
Update
https://developers.box.com/view/#put-documents-id
To update the metadata of a document, use $document->update()
.
Pass in the fields you want to update.
Right now, only the name
field is supported.
This function returns a boolean of whether the file was updated or not.
The response looks like this:
Delete
https://developers.box.com/view/#delete-documents-id
To delete a document, use $document->delete()
.
This function returns a boolean of whether the file was deleted or not.
The response looks like this:
Session
Fields
Field | Getter |
---|---|
id | $session->id() |
document | $session->document() |
expiresAt | $session->expiresAt() |
assetsUrl | $session->assetsUrl() |
realtimeUrl | $session->realtimeUrl() |
viewUrl | $session->viewUrl() |
Create
https://developers.box.com/view/#post-sessions
To create a session, use $document->createSession()
.
Pass in an optional associative array of params.
This function returns a Box\View\Session
object.
The response looks like this:
Delete
https://developers.box.com/view/#delete-sessions-id
To delete a session, use $session->delete()
.
This function returns a boolean of whether the session was deleted or not.
The response looks like this: