本文介绍了谷歌驱动器API添加共享文件夹到我的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个PHP脚本,用于在Google云端硬盘帐户中创建文件夹。一旦文件夹被创建,我将然后使用权限与我的谷歌应用程序域的其他用户分享。

我已经成功创建了这部分,现在我需要添加一个可以通过UI完成的功能,但是我找不到通过api完成的方法:
我想将该文件夹添加到用户的我的文件部分(可能位于子文件夹中)
导致用户界面可以完成到与我共享的文件部分,单击右键选择添加到我的文件



我如何以编程方式做到这一点?有一种方法吗?

编辑



我想在用户目录中以编程方式执行此操作





此时,我可以在用户目录中创建文件和文件夹,但我不知道如何添加共享文件夹其他用户

解决方案

我找到了我的问题的答案。我离开这里,所以如果有人需要它;)

要添加用户A的共享文件夹,在用户B我的文件中,您需要访问驱动器api以用户B的身份,获取共享文件夹(它具有与用户A实例中相同的标识),然后将该文件夹的根目录或用户B驱动器内的文件夹添加为该文件夹的父目录。

  $ about = $ userBServiceInstance-> about-> get(); 
$ userBRootFolderId = $ about-> getRootFolderId();

$ newParent = new Google_Service_Drive_ParentReference();
$ newParent-> setId($ userBRootFolderId);

$ userBServiceInstance->父母 - >插入($ folderId,$ newParent);


I'm creating a PHP script that will create folders within a Google Drive account. Once the folder is created I will then then share it using the permissions, with other users of my google apps domain.

I've created this part successfully, now I need to add a function that can be done througth the UI, but I can't find a way to do via api:I want to add the folder into the my files section of an users (possibly in a sub folder)Throught the UI can be done going to the "files shared with me" section, right clicking and selecting "add to my file"

How can i do that programmatically? There's a way?

EDIT

I want to do this programmatically in the users directory

http://i.stack.imgur.com/II3Q6.png

at the moment, I can create file and folder in the users directory, only I don't know how to add a folder shared from an other users

解决方案

I've found the answer to my question. I left here, so if someone need it ;)

To add a shared folder of user A, in user B "my files", you need to access the drive api using as user B, get the shared folder (it has the same id that it has in user A instance), and add as parent of that folder the root dir, or a folder inside the user B drive.

$about = $userBServiceInstance->about->get();
$userBRootFolderId = $about->getRootFolderId();

$newParent = new Google_Service_Drive_ParentReference();
$newParent->setId($userBRootFolderId);

$userBServiceInstance->parents->insert($folderId, $newParent);

这篇关于谷歌驱动器API添加共享文件夹到我的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 00:56