【发布时间】:2011-07-25 04:14:39
【问题描述】:
我正在尝试使用 Zend Framework 从 Google Docs 中名为“myfolder”的文件夹中检索文档列表。
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient("my@gmail.com", "password", $service);
$docs = new Zend_Gdata_Docs($client);
$feed = $docs->getDocumentListFeed('https://docs.google.com/feeds/documents/private/full/-/myfolder');
$this->view->feed = "";
foreach ($feed as $document) {
$link = $document->getLink();
$this->view->feed .= '<a href="'.$link[0]->getHref().'" target="_blank">'.$document->getTitle().'</a><br/>';
}
我能够获得“myfolder”中所有文件的列表;但是当我尝试打开它们时,出现错误:
需要授权
错误 401
我试过了
https://docs.google.com/feeds/documents/private/full
而不是
https://docs.google.com/feeds/documents/private/full/-/myfolder
我可以看到我的所有文件。我可以毫无问题地打开保存在“主”目录下的那些。仅当我尝试打开保存在文件夹中的文件时才会出现错误 401。
为什么?有什么想法吗?
【问题讨论】:
-
我正在回答我自己的问题...我应该使用
$link[1]->getHref()而不是$link[0]->getHref(),因为该文件离根目录只有一层。
标签: zend-framework google-docs google-docs-api