Php Google Drive API-子列表返回“;谷歌“Http请求”;取而代之的是;谷歌“服务”驱动“儿童列表”;
我下载了最新的Google Drive API sdk for PHP。我想上传特定文件夹和子文件夹中的几个文件。例如:Php Google Drive API-子列表返回“;谷歌“Http请求”;取而代之的是;谷歌“服务”驱动“儿童列表”;,php,google-api,google-drive-api,Php,Google Api,Google Drive Api,我下载了最新的Google Drive API sdk for PHP。我想上传特定文件夹和子文件夹中的几个文件。例如: item 1: folder1/folderA/file.png item 2: folder1/folderB/file.png item 3: folder1/folderC/file.png 我用这个方法建立了一个类 upload_file(local_path, remote_desination_folder)... 在该方法中,我有: paths = expl
item 1: folder1/folderA/file.png
item 2: folder1/folderB/file.png
item 3: folder1/folderC/file.png
我用这个方法建立了一个类
upload_file(local_path, remote_desination_folder)...
在该方法中,我有:
paths = explode("/", remote_destination_folder);
然后
parent_id = 0;
foreach(paths as path){
parent_id = this->create_folder(path, parent_id);
}
(这是伪代码…)
这段代码的问题是,如果我试图创建一个名为已存在的文件夹,则GoogleAPI将返回一个错误。(或者它将创建新文件夹,但文件将不在同一文件夹“folder1”中)
为了解决这个问题,我在循环中添加了方法listChildrens(folderId,folder_name)。此函数如下所示:
private function myListChildren(folderId,title)
{
qstr = "title = 'title' and mimeType='application/vnd.google-apps.folder' and trashed=false";
childs = this->service->children->listChildren(folderId,array('q' => qstr));
echo "Searching for title in folderId query= qstr...\n";
print_r(childs);
}
$qstr = "title = '$title' and mimeType='application/vnd.google-apps.folder' AND trashed = false AND '$folderId' in parents ";
$childs = $this->service->children->listChildren($folderId,array('q' => $qstr));
现在,最奇怪的是我不能理解:
如果找不到文件夹,它将返回包含空项数组的Google\u服务\u驱动器\u ChildList对象。若找到该文件夹,它将返回“Google\u Http\u请求”对象
我是遗漏了什么还是这是个错误
附言。
我在下一个链接上测试了查询,它可以工作:
请帮帮我,我累坏了
提前谢谢
更新2014-08-14 09:24(UTC+1):
你好
我刚刚尝试过这样的文件/列表调用:
private function myListChildren(folderId,title)
{
qstr = "title = 'title' and mimeType='application/vnd.google-apps.folder' and trashed=false";
childs = this->service->children->listChildren(folderId,array('q' => qstr));
echo "Searching for title in folderId query= qstr...\n";
print_r(childs);
}
$qstr = "title = '$title' and mimeType='application/vnd.google-apps.folder' AND trashed = false AND '$folderId' in parents ";
$childs = $this->service->children->listChildren($folderId,array('q' => $qstr));
但问题仍然存在…嗯,我发现问题出在哪里了 在upload_file()函数中,我有一个奇怪的上传过程。。。我认为这部分是有问题的:
$this->client->setDefer(true);
现在它工作得很好
我希望这将有助于以后的人 这是Dropbox上的完整文件:谢谢!