Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 1.83 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to move a google doc into a folder using Zend Gdata
  2. $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
  3. $client = Zend_Gdata_ClientLogin::getHttpClient($gUser, $gPass, $service);
  4. $link = "https://docs.google.com/feeds/documents/private/full/spreadsheet:0AUFNVEpLOVg2U0E"; // Not real id for privacy purposes
  5. $docs = new Zend_GData_Docs($client);
  6.  
  7. // Attach a category object of folder to this entry
  8. // I have tried many variations of this including attaching label categories
  9. $cat = new Zend_Gdata_App_Extension_Category('My Folder Name','http://schemas.google.com/docs/2007#folder');
  10.  
  11. $entry = $docs->getDocumentListEntry($link);
  12. $entry->setCategory(array($cat));
  13.  
  14. $return = $docs->updateEntry($entry,$entry->getEditLink()->href);
  15.        
  16. $folder = "https://docs.google.com/feeds/documents/private/full/folder%3A0wSFA2WHc";
  17. $rel = "http://schemas.google.com/docs/2007#parent";
  18.  
  19. $linkObj = new Zend_Gdata_App_Extension_Link($folder,$rel,'application/atom+xml', NULL,'Folder Name');
  20. $links = $entry->getLink();
  21. array_push($links,$linkObj);
  22. $entry->setLink($links);
  23.  
  24. $return = $docs->updateEntry($entry,$entry->getEditLink()->href);
  25.        
  26. // Folder you want to move too
  27. $folder = "https://docs.google.com/feeds/folders/private/full/folder%asdsad";
  28. $data = $docs->insertDocument($entry, $folder); // Entry is the entry you want moved using insert automatically assigns link & category for you...
  29.        
  30. $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
  31. $client = Zend_Gdata_ClientLogin::getHttpClient($gUser, $gPass, $service);
  32. $docs = new Zend_GData_Docs($client);
  33.  
  34. $link = "https://docs.google.com/feeds/documents/private/full/spreadsheet:0AUFNVEpLOVg2U0E";
  35. $entry = $docs->getDocumentListEntry($link);
  36. // Folder (Collection you want to move to)
  37. $folder = "https://docs.google.com/feeds/folders/private/full/folder%asdsad";
  38. // Move
  39. $data = $docs->insertDocument($entry, $folder);