Google api 使用Zend Gdata Google Docs API复制文档
我正在尝试确定如何使用Google Docs API Zend Gdata客户端制作文档副本 我有下面的代码,它正在访问DocumentList,并允许我检索单个条目Google api 使用Zend Gdata Google Docs API复制文档,google-api,zend-gdata,Google Api,Zend Gdata,我正在尝试确定如何使用Google Docs API Zend Gdata客户端制作文档副本 我有下面的代码,它正在访问DocumentList,并允许我检索单个条目 $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $sourceClient = Zend_Gdata_ClientLogin::getHttpClient($sourceUser, $sourcePass, $service); $sourceDocs = new Zend_Gda
$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链接
以下是我是如何做到的:电子表格
$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);
就是这样-对我有用!灵感来源于[gaetan frenoy]