'.print_r($out,1).''; } if (isset($_GET['view'])){//просмотр $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $httpClient = Zend_Gdata_ClientLogin::getHttpClient($username,$password,$service); $docs = new Zend_Gdata_Docs($httpClient); $feed = $docs->getDocumentListFeed(); foreach ($feed->entries as $entry) { $titleid=$entry->title; $fileid=$entry->id; $cut = substr($fileid, 64); echo ''.$titleid.' '.$entry->id.'
'; $contentLink = $entry->content->getSrc(); $fileContents = download($docs, $contentLink, 'html'); echo 'Contents of document "' . $entry->title . '":
'; echo '
'.$fileContents.'
'; } if (isset($_GET['id'])){//просмотр шв //echo ''; //echo ''; //echo '
'.print_r($this->getDoc($_GET['id'], 'document'),1).'
'; // TODO 1: setup a Zend_Gdata_Docs client in $docs_client // TODO 2: fetch a $feed or $entry /* $contentLink = $feed->entries[0]->content->getSrc(); $fileContents = download($docs, $contentLink, 'doc'); echo 'Contents of document "' . $feed->entries[0]->title . '":
'; echo '
'.print_r($fileContents).'
'; */ } /* A1iLc-Uiy2nHHM00x_0XjJ_uS3QSWwL4TiIKxGws9ZtNA - Resume A1_zGiFD6FX2P4Gx0Z8krP17Bh28zYgbTDk363SnyAmfs - Resume A1Dg04E36gIB1-OSopBOtQiggTsPzQ_IGvbyLF6pgYzIY - Resume A1Tp5jI1v5xZMYNZgRgyYxV_hLAJsfIiMiHW4NtTEj1Ss - Новый документ https://docs.google.com/document/d/1Tp5jI1v5xZMYNZgRgyYxV_hLAJsfIiMiHW4NtTEj1Ss/edit */ } //ПОЛУЧЕНИЕ ФАЙЛА В ВИДЕ $format - txt, html function download($client, $url, $format=null) { $sessionToken = $client->getHttpClient()->getAuthSubToken(); $opts = array( 'http' => array( 'method' => 'GET', 'header' => "GData-Version: 3.0\r\n". "Authorization: AuthSub token=\"$sessionToken\"\r\n" ) ); if ($url != null) { $url = $url . "&exportFormat=$format"; } return file_get_contents($url, false, stream_context_create($opts)); } //загрузка файла в доки function uploadDocument($docs, $originalFileName,$temporaryFileLocation) { $out = array(); $fileToUpload = $originalFileName; if ($temporaryFileLocation) { $fileToUpload = $temporaryFileLocation; } /*//удаление файлов перед загрузкой $query = new Zend_Gdata_Docs_Query(); $query->setTitle($originalFileName); $query->setTitleExact("true"); try { $doc = $docs->getDocumentListEntry($query); $docExists = true; } catch (Exception $e) { $docExists = false; } if ($docExists) { //echo 'Удаляю предыдущую версию документа '.$doc->title.'\n'; $doc->delete(); } */ $newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName,null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI); $out['title'] = $newDocumentEntry->title; foreach ($newDocumentEntry->link as $link) { if ($link->getRel() === 'alternate') { $out['link'] = $link->getHref(); } } return $out; } ?>