Zend_Gdata: Retrieving text document content?
Retrieving spreadsheet content usin开发者_运维百科g 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.
精彩评论