public function indexAction() { $content = new Content(); $slug = $this->_getParam('slug'); if ($slug == '\\d+') { $content = new Content(); $this->view->contents = $content->getFrontContent('treports'); $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($this->_config->webservice->google->username, $this->_config->webservice->google->password, $service); $docs = new Zend_Gdata_Docs($client); $docsQuery = new Zend_Gdata_Docs_Query(); $docsQuery->setQuery('title:Treasure Annual Report'); $feed = $docs->getDocumentListFeed($docsQuery); $documents = array(); foreach ($feed->entries as $entry) { $title = $entry->title; foreach ($entry->link as $link) { if ($link->getRel() === 'alternate') { $altlink = $link->getHref(); } } $documents[] = array('title' => $title, 'altlink' => $altlink, 'updated' => $entry->updated, 'type' => $entry->content->type, 'published' => $entry->published); } $this->view->documents = $documents; } else { $this->view->contents = $content->getContent('treports', $this->_getParam('slug')); } }
/** Render documents on the index page */ public function indexAction() { $content = new Content(); $this->view->contents = $content->getFrontContent('publications'); $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($this->_helper->config->webservice->google->username, $this->_config->webservice->google->password, $service); $docs = new Zend_Gdata_Docs($client); $feed = $docs->getDocumentListFeed(); $documents = array(); foreach ($feed->entries as $entry) { $title = $entry->title; foreach ($entry->link as $link) { if ($link->getRel() === 'alternate') { $altlink = $link->getHref(); } } $documents[] = array('title' => $title, 'altlink' => $altlink, 'updated' => $entry->updated, 'type' => $entry->content->type, 'published' => $entry->published); } $this->view->documents = $documents; }
function testGdataAction() { $this->disableLayout(); $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient("*****@*****.**", "W1sedsuk0l", $service); $docs = new Zend_Gdata_Docs($client); $feeds = $docs->getDocumentListFeed(); foreach ($feeds as $feed) { //echo get_class($feed); //$feed = new Zend_Gdata_Docs_DocumentListEntry(); $links = array(); foreach ($feed->getLink() as $link) { //$link = new Zend_Gdata_App_Extension_Link; $links[] = $link->getHref(); //print_r($link->getHref()) ; } $href = $links[0]; echo "<a href='{$href}'>", $feed->getTitle(), "</a>", '<br/>|'; echo '<br/>|', $feed->getEditLink(), '<br/>|', $feed->getSummary() . '<hr/><br/>'; } $this->render('blank', null, true); }
/** * Obtain a list of all of a user's docs.google.com documents * which match the specified search criteria and print the titles to the * command line. * * @param Zend_Gdata_Docs $client The service object to use for communicating with the Google * Documents server. * @param boolean $html True if output should be formatted for display in a web browser. * @param string $query The search query to use * @return void */ function fullTextSearch($client, $html, $query) { if ($html) { echo "<h2>Documents containing {$query}</h2>\n"; } $feed = $client->getDocumentListFeed('http://docs.google.com/feeds/documents/private/full?q=' . $query); printDocumentsFeed($feed, $html); }
case 'request_token': $_SESSION['REQUEST_TOKEN'] = serialize($consumer->fetchRequestToken(implode(' ', $scopes), $APP_URL . '?action=access_token')); $consumer->authorizeRequestToken(); break; case 'access_token': $_SESSION['ACCESS_TOKEN'] = serialize($consumer->fetchAccessToken()); header('Location: ' . $APP_URL); break; default: if (isset($_SESSION['ACCESS_TOKEN'])) { $accessToken = unserialize($_SESSION['ACCESS_TOKEN']); $httpClient = $accessToken->getHttpClient($consumer->getOauthOptions()); $docsService = new Zend_Gdata_Docs($httpClient, $APP_NAME); $spreadsheetsService = new Zend_Gdata_Spreadsheets($httpClient, $APP_NAME); // Retrieve user's list of Google Docs and spreadsheet list. $docsFeed = $docsService->getDocumentListFeed(); $spreadsheetFeed = $spreadsheetsService->getSpreadsheetFeed('http://spreadsheets.google.com/feeds/spreadsheets/private/full?max-results=100'); renderHTML($accessToken, array($docsFeed, $spreadsheetFeed)); } else { renderHTML(); } } /** * Returns a the base URL of the current running web app. * * @return string */ function getAppURL() { $pageURL = 'http'; if ($_SERVER['HTTPS'] == 'on') {
} $request_token = @$_REQUEST['openid_ext2_request_token']; if ($request_token) { $data = array(); $httpClient = new Zend_Gdata_HttpClient(); $access_token = getAccessToken($request_token); // Query the Documents API =================================================== $feedUri = 'http://docs.google.com/feeds/documents/private/full'; $params = array('max-results' => 50, 'strict' => 'true'); $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, $params); $req->sign_request($sig_method, $consumer, $access_token); // Note: the Authorization header changes with each request $httpClient->setHeaders($req->to_header()); $docsService = new Zend_Gdata_Docs($httpClient); $query = $feedUri . '?' . implode_assoc('=', '&', $params); $feed = $docsService->getDocumentListFeed($query); $data['docs']['html'] = listEntries($feed); $data['docs']['xml'] = $feed->saveXML(); // =========================================================================== // Query the Spreadsheets API ================================================ $feedUri = 'http://spreadsheets.google.com/feeds/spreadsheets/private/full'; $params = array('max-results' => 50); $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, $params); $req->sign_request($sig_method, $consumer, $access_token); // Note: the Authorization header changes with each request $httpClient->setHeaders($req->to_header()); $spreadsheetsService = new Zend_Gdata_Spreadsheets($httpClient); $query = $feedUri . '?' . implode_assoc('=', '&', $params); $feed = $spreadsheetsService->getSpreadsheetFeed($query); $data['spreadsheets']['html'] = listEntries($feed); $data['spreadsheets']['xml'] = $feed->saveXML();