PHP code example of jpcaparas / box-sdk

1. Go to this page and download the library: Download jpcaparas/box-sdk 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/ */

    

jpcaparas / box-sdk example snippets


use Linkstreet\Box;
use Linkstreet\Box\Enums\SubscriptionType;

$box_sdk = new Box(['client_id' => "", "client_secret" => ""]);

$app_auth_info = [
    "key_id" => "key id from box app",
    "private_key" => "path to private key",
    "pass_phrase" => "passphrase", // Can be empty
    "subscription_type" => SubscriptionType::ENTERPRISE or SubscriptionType::USER,
    "id" => "enterprise id or user id"
];

// Authenticates with box server and returns app_auth instance.
// Throws `GuzzleHttp\Exception\ClientException` on failure 
$app_auth_instance = $box_sdk->getAppAuthClient($app_auth_info);

    $folder_service = $app_auth_instance->getFolderService();
    

    $file_service = $app_auth_instance->getFileService();