Google Docs API 文档列表和两个同名文件夹
我使用 PHP 获取文件夹列表,然后获取 Google Docs 中的文档(两个 API 请求)。
获取文件夹列表,我可以获得它们的folderID,这很好。
但是,当获取文档列表时,它会返回类别,并且这些类别仅包含文件夹的名称。
我的问题存在是因为我有两个同名的文件夹,并且我的代码正在合并这些文件夹中的文档,因为它们具有相同的名称。
我用来获取文件夹内文档列表的函数:
/**
* Gets a list of 'internal' IDs of docs within a certain folder
* @global Mixed $fileslist
* @param String $folder
* @return Array
*/
function getDocumentsInFolder($folder) {
global $fileslist;
$docs = array();
foreach ($fileslist as $id => $files) {
if (in_array($folder, $files['folders'])) {
$docs[] = $id;
}
}
return $docs;
}
数组为:
foreach ($list[$i]->category as $cat) {
$folders[] = $cat->label;
}
$folderslist[$i] = array(
'name' => $foldername,
'authorname' => $authorname,
'authoremail' => $authoremail,
'lastupdated' => $lastupdated,
'fid' => $fid
);
$fileslist[] = array(
'name' => $name,
'authorname' => $authorname,
'authoremail' => $authoremail,
'lastupdated' => $lastupdated,
'folders' => $folders,
'id' => $id,
'type' => $list[$i]->extensionElements[0]->text,
);
用于文档列表的 Google Docs API 的 XML 为 @ http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ListDocs(请注意类别只是文件夹名称)。
有什么想法如何阻止文件出现在该文件夹名称的所有实例中,并且仅出现在其正确的文件夹中?
I use PHP to get a list of folders, and then documents from Google Docs (two API requests).
Getting a list of the folders, I can get their folderID, which is fine.
However, when getting a list of documents, it returns categories, and these only contain the name of the folder.
My problem exists because I have two folders with the same name, and my code is merging the documents from these, because they have the same name.
The function I use to get a list of the documents within the folder:
/**
* Gets a list of 'internal' IDs of docs within a certain folder
* @global Mixed $fileslist
* @param String $folder
* @return Array
*/
function getDocumentsInFolder($folder) {
global $fileslist;
$docs = array();
foreach ($fileslist as $id => $files) {
if (in_array($folder, $files['folders'])) {
$docs[] = $id;
}
}
return $docs;
}
And the arrays are:
foreach ($list[$i]->category as $cat) {
$folders[] = $cat->label;
}
$folderslist[$i] = array(
'name' => $foldername,
'authorname' => $authorname,
'authoremail' => $authoremail,
'lastupdated' => $lastupdated,
'fid' => $fid
);
$fileslist[] = array(
'name' => $name,
'authorname' => $authorname,
'authoremail' => $authoremail,
'lastupdated' => $lastupdated,
'folders' => $folders,
'id' => $id,
'type' => $list[$i]->extensionElements[0]->text,
);
The XML the Google Docs API for the list of documents is @ http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ListDocs (Note how the categories are just folder names).
Any ideas how to stop files appearing in all instances of that folder name, and just in their proper folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已修复:)
文档列表返回:
其中包含文件夹 ID,我能够将其存储在文档列表中然后进行比较。
Fixed it :)
The document list returns:
Which contains the folder ID, I was able to store this in the document list and then compare.