0

Google Docs APIZendGdataクライアントを使用してドキュメントのコピーを作成する方法を決定しようとしています。

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

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 に答える