![](/img/trans.png)
[英]How we can download a google docs into our local (computer)/hard drive using google docs api with PHP?
[英]How we can get permission Id from a google drive api using PHP?
我想要一个权限 ID 来使用谷歌驱动器 api 和 PHP 更新我对谷歌驱动器中文件的用户权限。谁能告诉我如何从响应中获取权限 ID。 我经历了这个https://developers.google.com/drive/api/v2/reference/permissions/update 。 在此我需要权限 ID 来更新我的权限,但我无法获得它。 谁能告诉我如何使用 PHP 以编程方式获取它。获取权限 ID 的确切方法是什么。
要从Google Drive 上的文件中检索权限ID,您可以使用Drive API 的“Permissions: list”方法进行检索。
根据您提供的 URL,如果您使用的是 Drive API v2,则可以使用以下脚本。
$fileId = "###"; // Please set the file ID.
$drive = new Google_Service_Drive($client); // Please use your authorization script.
$res = $drive->permissions->listPermissions($fileId);
$permissions = $res->getItems();
foreach ($permissions as &$p) {
$id = $p->getId();
print($id . "\n");
}
如果您使用的是 Drive API v3,则可以使用以下脚本。
$fileId = "###"; // Please set the file ID.
$drive = new Google_Service_Drive($client); // Please use your authorization script.
$res = $drive->permissions->listPermissions($fileId);
$permissions = $res->getPermissions();
foreach ($permissions as &$p) {
$id = $p->getId();
print($id . "\n");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.