gpenverne / putio-drive-sdk
用于探索putio文件的组件
0.1.39
2017-07-29 15:08 UTC
Requires
- php: >=5.4
- gpenverne/psr-cloud-files: dev-master
- guzzlehttp/guzzle: ~6.0
- nicoswd/putio: 0.3.*
- symfony/class-loader: *
- symfony/config: *
- symfony/dependency-injection: *
- symfony/framework-bundle: *
- symfony/http-kernel: *
Requires (Dev)
README
## 安装 安装组件
$ composer require gpenverne/putio-drive-sdk
在AppKernel中加载组件
new Gpenverne\PutioDriveBundle\PutioDriveBundle(),
配置
parameters:
putio:
client_id: your-client-id
client_secret: your-client-secret
callback_route: callback_route
在callback_route(例如,显示成功消息)中添加您自定义的路由
将端点添加到您的routing.yml中或使用我们的控制器端点
putio.callback:
path: /putio/callback
defaults: { _controller: putio.drive.controller:callbackAction }
putio.redirect:
path: /putio/redirect
defaults: { _controller: putio.drive.controller:redirectAction }
获取用户令牌
调用之前创建的路由(putio.redirect)。权限授予后,用户将被重定向到之前配置的"callback_route"参数
检索令牌
获取令牌后,将触发"events.putio.token"事件。
此事件由putio drive服务处理,您可以使用putio.drive服务检索它
// In a controller: $token = $this->container->get('putio.drive')->getToken();
使用putio php sdk
您可以使用我们内置的文件/文件夹查找器
$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.cn/packages/gpenverne/psr-cloud-files] $files = $folder->getFiles(); // Or retrieve a full path file // Will return FileInterface // cf. (psr-cloud-files)[https://packagist.org.cn/packages/gpenverne/psr-cloud-files] $file = $putioDrive->findByPath('/MyMovies/MyMovie.mp4'); // Retrieving the download url: $file = $putioDrive->findByPath('/MyMovies/MyMovie.mp4'); $downloadUrl = $file->getLink();
感谢 https://github.com/nicoSWD/put.io-api-v2,您可以轻松进行API调用
// 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');