开发者

List and open Google Docs from a folder using Zend Framework

开发者 https://www.devze.com 2023-03-22 10:45 出处:网络
I\'m trying to retrieve a list of documents from a folder named \"myfolder\" in Google Docs using Zend Framework.

I'm trying to retrieve a list of documents from a folder named "myfolder" in Google Docs using Zend Framework.

$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/docu开发者_StackOverflow中文版ments/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/>';
}

I was able to get a list of all files in "myfolder"; but when I try to open them, I get an error:

Authorization required

Error 401

I've tried using

https://docs.google.com/feeds/documents/private/full

instead of

https://docs.google.com/feeds/documents/private/full/-/myfolder

and I'm able to see all my files. I can open those that are saved under the "Home" directory without any problem. The Error 401 only happens when I try to open files that are saved in a folder.

Why? Any idea?


Should have used $link[1]->getHref() instead of $link[0]->getHref().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号