PHP code example of gpenverne / putio-drive-sdk

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

    

gpenverne / putio-drive-sdk example snippets


    new Gpenverne\PutioDriveBundle\PutioDriveBundle(),

// In a controller:
$token = $this->container->get('putio.drive')->getToken();

$putioDrive = $this->container->get('putio.drive');
$putioDrive->setToken($token);

// Retrieving a folder
$folder = $putioDrive->findByPath('/MyMovies');

// Retrieving files in the folder
// Will return FileInterface and FolderInterface
// cf. (psr-cloud-files)[https://packagist.org/packages/gpenverne/psr-cloud-files]
$files = $folder->getFiles();

// Or retrieve a full path file
// Will return FileInterface
// cf. (psr-cloud-files)[https://packagist.org/packages/gpenverne/psr-cloud-files]
$file = $putioDrive->findByPath('/MyMovies/MyMovie.mp4');

// Retrieving the download url:
$file = $putioDrive->findByPath('/MyMovies/MyMovie.mp4');
$downloadUrl = $file->getLink();

// In a controller, using the previous catched token:
$putioApiClient = $this->container->get('putio.drive')->getApiClient();

// In a controller, using a custom token:
$putioApiClient = $this->container->get('putio.drive')->getApiClient('custom token');