2017 © Pedro PelĂĄez
 

bundle putio-drive-sdk

A bundle for explore putio files

image

gpenverne/putio-drive-sdk

A bundle for explore putio files

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 24 Versions
  • 0 % Grown

The README.md

putio-drive-sdk

 Installation

Install the bundle:, (*1)

$ composer require gpenverne/putio-drive-sdk

Load bunle in AppKernel:, (*2)

    new Gpenverne\PutioDriveBundle\PutioDriveBundle(),

Configuration

parameters:
    putio:
        client_id: your-client-id
        client_secret: your-client-secret
        callback_route: callback_route

With your custom route in callback_route (for example, to display a success message), (*3)

Add your endpoints to your routing.yml or use our controllers endpoints:, (*4)

putio.callback:
    path:     /putio/callback
    defaults: { _controller: putio.drive.controller:callbackAction }

putio.redirect:
    path:     /putio/redirect
    defaults: { _controller: putio.drive.controller:redirectAction }

obtain the user token

Call the previous created route (putio.redirect) . After access granted, user will be redirected to previous configured "callback_route" parameter, (*5)

retrieving the token

Once token obtained, "events.putio.token" event is dispatched.
This event is handled by putio drive service, and you can retrieve it using putio.drive service:, (*6)

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

using the putio php sdk

You can use our builtin file/folder finder:, (*7)

$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();

Thanks to https://github.com/nicoSWD/put.io-api-v2, you can easily make api calls:, (*8)

// 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');

The Versions