Wrapper in PHP for the Box.com API
Add the following lines to your composer.json:
"repositories": [
{
"type": "git",
"url": "https://github.com/henrikromby/box"
}
],
"require": {
"henrikromby/box": "dev-master"
}
(until it's submited to packagist)
$http = new \Romby\Box\Http\Adapters\GuzzleHttpAdapter(new \GuzzleHttp\Client())
$folders = new \Romby\Box\Services\Folders($http);
$files = new \Romby\Box\Services\Files($http);
$comments = new \Romby\Box\Services\Comments($http);
$collaborations = new \Romby\Box\Services\Collaborations($http);
$sharedItems = new \Romby\Box\Services\SharedItems($http);
$users = new \Romby\Box\Services\Users($http);
$tasks = new \Romby\Box\Services\Tasks($http);
$groups = new \Romby\Box\Services\Groups($http);
$search = new \Romby\Box\Services\Search($http);
// Get Input
$file = Input::file('file');
// Extract data from file
$path = $file->getRealPath();
$name = $file->getClientOriginalName();
// Specify the parent_id for the folder
$parent_id = "0" // 0 = root of your box.com folder
// Insert your token here
$token = "Your API Key";
$BoxFile = new \Romby\Box\Services\Files($http);
$resp = $BoxFile->upload($token, $path, $name, $parent);
You can refer to the documentation here