创建Google Drive的Google服务包装库。

v0.1.1 2019-04-23 00:54 UTC

This package is auto-updated.

Last update: 2024-09-23 12:35:37 UTC


README

Build Status codecov License composer.lock

该软件包是为我正在工作的项目创建的,并不完全支持Google服务(或您可能希望的方式)。请随意通过创建拉取请求来添加功能。请参阅贡献指南

安装

您可以通过composer安装此软件包

$ composer require basecardhero/drive

使用方法

您需要配置Google客户端。请参阅gsuitedevs/php-samples以获取配置php Google客户端的示例。

示例

创建Drive实例

require_once '/project/path/vendor/autoload.php';

$client = new \Google_Client(); // Make sure to configure your Google client.
$driveService = new \Google_Service_Drive($client);
$drive = new \BaseCardHero\Drive\Drive($driveService);

获取Google_Service_Drive实例

$drive->getService() // \Google_Service_Drive

检索文件

$file = $drive->get('efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

设置文件权限

$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';
$permissions = $drive->setPermission($fileId, 'anyone', 'reader');

echo get_class($permissions); // \Google_Service_Drive_Permission

创建文件

请参阅MIME类型

$file = $drive->create('My File', 'application/vnd.google-apps.file');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

创建文件夹

$folder = $drive->createFolder('My Folder');

echo get_class($folder); // \Google_Service_Drive_DriveFile
echo $folder->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

删除文件

$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';

$drive->delete($fileId); // null

测试

$ composer all

变更日志

请参阅变更日志以获取更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过ryan@basecardhero.com发送电子邮件,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

PHP软件包模板

该软件包是使用PHP软件包模板生成的。