1

嗨,伙计们,我真的很难使用 zend gdata 将文档从我的根文件夹移动到另一个文件夹,这就是我尝试这样做的方式,但它不起作用。

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($gUser, $gPass, $service);
$link = "https://docs.google.com/feeds/documents/private/full/spreadsheet:0AUFNVEpLOVg2U0E"; // Not real id for privacy purposes
$docs = new Zend_GData_Docs($client);

// Attach a category object of folder to this entry
// I have tried many variations of this including attaching label categories
$cat = new Zend_Gdata_App_Extension_Category('My Folder Name','http://schemas.google.com/docs/2007#folder');

$entry = $docs->getDocumentListEntry($link);
$entry->setCategory(array($cat));

$return = $docs->updateEntry($entry,$entry->getEditLink()->href);

当我运行它时,我得到没有错误,但似乎没有任何变化,并且返回数据不包含新类别。

编辑: 好的,我意识到它不是类别,而是决定资源属于哪个“集合”(文件夹)的链接。https://developers.google.com/google-apps/documents-list/#managing_collections_and_their_contents说每个资源都有父链接,所以我尝试将代码更改为设置链接而不是设置类别,但这并没有工作。

$folder = "https://docs.google.com/feeds/documents/private/full/folder%3A0wSFA2WHc";
$rel = "http://schemas.google.com/docs/2007#parent";

$linkObj = new Zend_Gdata_App_Extension_Link($folder,$rel,'application/atom+xml', NULL,'Folder Name');
$links = $entry->getLink();
array_push($links,$linkObj);
$entry->setLink($links);

$return = $docs->updateEntry($entry,$entry->getEditLink()->href);

编辑:已解决 [几乎] 好的 这里是如何从一个文件夹移动/复制到另一个文件夹:比最初想象的要简单,但问题是它创建了一个引用而不是移动!它现在同时在两个地方......

// Folder you want to move too
$folder = "https://docs.google.com/feeds/folders/private/full/folder%asdsad";
$data = $docs->insertDocument($entry, $folder); // Entry is the entry you want moved using insert automatically assigns link & category for you...
4

1 回答 1

0

要将文件复制/移动到文件夹中,请执行以下操作:

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($gUser, $gPass, $service); 
$docs = new Zend_GData_Docs($client);

$link = "https://docs.google.com/feeds/documents/private/full/spreadsheet:0AUFNVEpLOVg2U0E";
$entry = $docs->getDocumentListEntry($link);
// Folder (Collection you want to move to)
$folder = "https://docs.google.com/feeds/folders/private/full/folder%asdsad";
// Move
$data = $docs->insertDocument($entry, $folder);

现在有些问题是:

  1. 它似乎只制作参考副本,这意味着它仍然是同一个文档,只是它有一个额外的类别和父链接(所以它现在在两个地方)。这可以更好地解释它:https ://groups.google.com/forum/embed/?place=forum/google-documents-list-api#!topic/google-documents-list-api/OrLi2JCINw4

我确信必须有一种方法可以“更清洁”/更好地做到这一点,但至少它现在可以移动它。

于 2012-06-03T11:12:02.537 回答