PHP code example of ziggeo / simple-box-integration

1. Go to this page and download the library: Download ziggeo/simple-box-integration library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ziggeo / simple-box-integration example snippets


use Ziggeo\BoxContent\Base\BoxApp;
use Ziggeo\BoxContent\Base\BoxMain;
use Ziggeo\BoxContent\Content\BoxFile;
use Ziggeo\BoxContent\Base\Exceptions\BoxClientException;


$boxApp = new BoxApp("clientID", "clientSecret", "accessToken");

$boxMain = new BoxMain($boxApp);

$boxFile = new BoxFile("/path/to/file.txt");

$folder = $boxMain->createFolder("FolderName");

try {
$file = $boxMain->upload($boxFile, array("parent" => array("id" => $folder->getId()), "name" => "file_name_in_box.txt"));
$resp = $boxMain->deleteFile($file->getId());
} catch (BoxClientException $exception) {
    echo $exception->getMessage();
}



$boxApp = new BoxApp("clientID", "clientSecret", "accessToken");

$boxMain = new BoxMain($boxApp);
$resp = $boxMain->sendRequest("/users/me", "api", array(), "accessToken");