0

我正在尝试确定如何使用 Google Docs API Zend Gdata 客户端制作文档副本。

我有以下代码正在访问 DocumentList 并允许我检索各个条目。

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;

$sourceClient = Zend_Gdata_ClientLogin::getHttpClient($sourceUser, $sourcePass, $service);

$sourceDocs = new Zend_Gdata_Docs($sourceClient);

$entry = new Zend_Gdata_Docs_DocumentListEntry();

$docfeed = $sourceDocs->getDocumentListFeed();

foreach ($docfeed->entries as $entry)
{
      $entry->getTitleValue();
}

我正在尝试确定如何制作特定文档条目的副本,而无需下载然后重新上传。我知道它可以基于 API 文档来完成,但是这个例子是在 .NET 中给出的,它似乎并没有很好地翻译成 PHP。

谷歌文档 API 链接 https://developers.google.com/google-apps/documents-list/#copying_documents

4

1 回答 1

0

我是这样做的:(电子表格)

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$sourceClient = Zend_Gdata_ClientLogin::getHttpClient($sourceUser, $sourcePass, $service);
$connection = new Zend_Gdata_Spreadsheets($sourceClient);

// Get the Id of a sheet you want to copy [ensure its an object]
$titleOfSheetToCopy = 'CopyMe';
$feed = $connection->getSpreadsheetFeed();
foreach($feed as $entry) {
  if($entry->getTitle() == $titleOfSheetToCopy) {
    // this is a url string so you need to clean it
    $data = (string)$entry->getId();
    $data = explode("/",$data);
    $id = array_pop($data);
  }
}

// Create blank Entry Object       
$blankEntry = new Zend_Gdata_Spreadsheets_SpreadsheetEntry();

// Set title
$blankEntry->setTitle(new Zend_Gdata_App_Extension_Title("My new spreadsheet", null));

// Set the id to the id of the sheet you want to copy (we got that above)
$blankEntry->setId(new Zend_Gdata_App_Extension_Id($id);

就是这样-对我有用!灵感来自如何使用 Zend GData [gaetan-frenoy]创建一个空的电子表格

于 2012-05-17T12:10:31.870 回答