【问题标题】:Copy a Document using Zend Gdata Google Docs API使用 Zend Gdata Google Docs API 复制文档
【发布时间】:2012-06-07 12:29:56
【问题描述】:

我正在尝试确定如何使用 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。

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

【问题讨论】:

    标签: google-api zend-gdata


    【解决方案1】:

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

    $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);
    

    就是这样 - 对我有用!灵感来自How to create an empty spreadsheet using Zend GData [gaetan-frenoy]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 2012-05-07
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多