PHP code example of prasadchinwal / box

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

    

prasadchinwal / box example snippets


    use PrasadChinwal\Box\Facades\Box;
    Box::file()->whereId('1234')->info();
    

    use PrasadChinwal\Box\Facades\Box;
    Box::file()->whereId('1234')->downloadFile();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    $attributes = [
        'shared_link' => [
            'access' => 'company',
            'permissions' => [
                'can_download' => true,
                'can_edit' => true,
            ]
        ]
    ];
    Box::file()->whereId('1234')->createSharedLink(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\BoxFile;
    $sharedLink = 'https://my.box.com/s/xasddyuejhkljawd';
    Box::file()->whereLink($sharedLink)->find();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1234')->getSharedLink();
    

    use PrasadChinwal\Box\Facades\BoxFile;
     Box::file()->whereId('1234')->thumbnail(extension: '.jpg');
    

    use PrasadChinwal\Box\Facades\BoxFile;
    $attributes = [
        'name' => 'TestFile.pdf', // An optional new name for the copied file.
        'parent' => [
            'id' => '4321' // The ID of folder to copy the file to.
        ],
        'version' => null // An optional ID of the specific file version to copy.
    ];
    Box::file()->whereId('1234')->copy(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\BoxFile;
    $attributes = [
        'name' => 'Test.pdf',  // An optional different name for the file. This can be used to rename the file.
        'description' => 'Testing update api.', //The description for a file. This can be seen in the right-hand sidebar panel when viewing a file in the Box web app. Additionally, this index is used in the search index of the file, allowing users to find the file by the content in the description.
        'disposition_at' => '2023-12-12T10:53:43-08:00', // The retention expiration timestamp for the given file. This date cannot be shortened once set on a file.
        'lock' => [ // Defines a lock on an item. This prevents the item from being moved, renamed, or otherwise changed by anyone other than the user who created the lock.
            'access' => 'lock',  // The type of this object. Value is always lock
            'expiration_at' => '',  // Defines the time at which the lock expires.
            'is_download_prevented' => false,  // Defines if the file can be downloaded while it is locked.
        ],
        'parent' => [  // An optional new parent folder for the file. This can be used to move the file to a new folder.
            'id' => ''  // The ID of parent item
        ],
        'permissions' => [  // Defines who can download a file.
            'can_download' => 'open'  // Defines who is allowed to download this file. The possible values are either open for everyone or company for the other members of the user's enterprise.
        ],
        'shared_link' => [  // Defines a shared link for a file. Set this to null to remove the shared link.
            'access' => '',  // The level of access for the shared link. This can be restricted to anyone with the link (open), only people within the company (company) and only those who have been invited to the folder (collaborators).
            'password' => '',  // The password 

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1234')->delete();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    $attributes = [
        'attributes' => json_encode(['name' => 'New_Test.pdf', 'parent' => ['id' => '4321']]),
    ];  // For full list of available options please see the docs.
    $filePath = storage_path('app/file.pdf');
    Box::file()->create(filepath: $filePath, filename: 'My_New_File.pdf',  attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1234')->versions();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1234')->getWatermark();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1234')->createWatermark();
    

    use PrasadChinwal\Box\Facades\BoxFile;
    Box::file()->whereId('1248628118855')->removeWatermark();
    

    use PrasadChinwal\Box\Facades\Box;
    Box::folder()->whereId('4321')->info();
    

        Box::folder()->whereId('4321')->items();
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'folder_upload_email' => [  // Setting this object enables the upload email address. This email address can be used by users to directly upload files directly to the folder via email.
            'access' => ''  // When this parameter has been set, users can email files to the email address that has been automatically created for this folder. Value is one of open,collaborators
        ],
        'name' => '',  // The name for the new folder. max length 255
        'parent' => [  // The parent folder to create the new folder within
            'id' => ''  // The ID of parent folder
        ],
        'sync_state' => ''  // Specifies whether a folder should be synced to a user's device or not. This is used by Box Sync (discontinued) and is not used by Box DriveSpecifies whether a folder should be synced to a user's device or not. This is used by Box Sync (discontinued) and is not used by Box Drive. Value is one of synced,not_synced,partially_synced
    ];
    Box::folder()->whereId('4321')->create(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'can_non_owners_invite' => [  // Specifies if users who are not the owner of the folder can invite new collaborators to the folder.
            'can_non_owners_view_collaborators' => '',  // Restricts collaborators who are not the owner of this folder from viewing other collaborations on this folder. It also restricts non-owners from inviting new collaborators. It also restricts non-owners from inviting new collaborators.
        ],
        'collections' => [  // An array of collections to make this folder a member of. Currently we only support the favorites collection.
            'id' => '',  // The unique identifier for this object
            'type' => '', // The type for this object
        ],
        'description' => '',  // The optional description of this folder
        'folder_upload_email' => [  // Setting this object enables the upload email address. This email address can be used by users to directly upload files directly to the folder via email.
            'access' => '',  // When this parameter has been set, users can email files to the email address that has been automatically created for this folder. To create an email address, set this property either when creating or updating the folder.
        ],
        'is_collaboration_restricted_to_enterprise' => '',  // Specifies if new invites to this folder are restricted to users within the enterprise. This does not affect existing collaborations.
        'name' => '',  // The optional new name for this folder.
        'parent' => [  // The parent folder to create the new folder within
            'id' => '212346363047'  // The ID of parent folder
        ],
        'shared_link' => [  // Enables the creation of a shared link for a folder.
            'access' => '',  // The level of access for the shared link. This can be restricted to anyone with the link (open), only people within the company (company) and only those who have been invited to the folder (collaborators). If not set, this field defaults to the access level specified by the enterprise admin. To create a shared link with this default setting pass the shared_link object with no access field, for example { 'shared_link': {} }.
            'password' => '',  // The password 

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'name' => 'Test',  // The name for the new folder. max length 255
        'parent' => [  // The parent folder to create the new folder within
            'id' => '54321'  // The ID of parent folder
        ],
    ];
    Box::folder()->whereId('4321')->copy(attributes: $attributes);
    

        Box::folder()->whereId('4321')->delete(recursive: true);
    

    use PrasadChinwal\Box\Facades\Box;
    Box::folder()->whereLink('https://test.box.com/s/dad4dasdcddasd')->find();
    

    use PrasadChinwal\Box\Facades\Box;
    Box::folder()->whereId('4321')->getSharedLink();
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'shared_link' => [
            'access' => 'company',
            'permissions' => [
                'can_download' => true,
            ]
        ]
    ];
    Box::folder()->whereId('4321')->createSharedLink(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\Box;
    Box::folder()->whereId('4321')->getLocks();
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'folder' => [
            'type' => '',
            'id' => '4321'
        ],
        'locked_operations' => [
            'move' => true,
            'delete' => true,
        ]
    ];
    Box::folder()->lock(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\Box;
    Box::folder()->unlock(lockid: '0983');
    

    use PrasadChinwal\Box\Facades\Box;
    Box::whereId('45678')->get();
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'item' => [
            'type' => 'folder',
            'id' => '4321',
        ],
        'accessible_by' => [
            'type' => 'user',
            'login' => '[email protected]'
        ],
        'role' => 'editor'
    ];
     Box::create(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\Box;
    $attributes = [
        'can_view_path' => true,
        'status' => 'accepted',  // pending / accepted / rejected
        'role' => 'editor'  // editor / viewer / previewer / uploader / previewer / uploader / viewer / uploader / co-owner / owner
    ];
    Box::whereId('1111')->update(attributes: $attributes);
    

    use PrasadChinwal\Box\Facades\Box;
    Box::collaboration()->whereId('1111')->delete();
    

    use PrasadChinwal\Box\Facades\Box;
    Box::user()->get();
    

    use PrasadChinwal\Box\Facades\Box;
    Box::user()->whereId('3477983675')->memberships();