当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Zend_Gdata: Retrieving text document content?

问题描述:

Retrieving spreadsheet content using for a specific spreadsheet isn't that hard:

$key = 'txSLYk4BpIQaglM38cJbTNA'; // key for a specific spreadsheet

$query = new Zend_Gdata_Spreadsheets_DocumentQuery();

$query->setSpreadsheetKey($key);

$feed = $spreadSheetService->getWorksheetFeed($query);

$entries = $feed->entries[0]->getContentsAsRows();

var_dump($entries); // dumps the spreadsheet content

Can I do the same for a specific text document?

The Zend_Gdata_Docs_Query class doesn't have a ->setDocumentKey($key) or equivalent...

/ Jonas

网友答案:

(note: I haven't worked with ZF's GData API myself... this is speculative, based on browsing through the API)

It looks like you can call Zend_Gdata_Docs::getDoc() - this will return a Zend_Gdata_Docs_DocumentListEntry which in turn exposes a getContent() method.

So:

$docsApi  = new  Zend_Gdata_Docs();
$document = $docsApi->getDoc('key-goes-here', 'document');
$content  = $document->getContent(); // Returns the ATOM content
// OR...
$content  = $document->getDOM(); // Returns a DOM for the content

It looks like the spreadsheet is a more specialised form of this more generic way of retrieving Google Docs content.

分享给朋友:
您可能感兴趣的文章:
随机阅读: