嗨,伙计们,我真的很难使用 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...