Posted a tip on this: http://gdatatips.blogspot.com/2009/07/download-google-doc-using-php-library.html
On Jul 15, 1:13 pm, "Eric (Google)" <api.e...@google.com> wrote: > Hi, > > You should be using the <entry>'s content src link > and not the alternate (/View?docID=...) link that > points to Google Docs. Having said that, > you'll need to write a download method yourself > b/c the Zend_Gdata_Docs component doesn't contain > this latest API feature. > > Here's how you _could_ use file_get_contents() to > export a doc as a .txt file. Note: to export > spreadsheets, you'll need a valid AuthSub session > token for scope=http://spreadsheets.google.com/feeds/ > as well. > > $feed = $gdClient->getDocumentListFeed( > 'http://docs.google.com/feeds/documents/private/full/-document'); > > // download first entry > $contentLink = $feed->entries[0]->content->getSrc(); > $fileContents = download($gdClient, $contentLink, 'txt'); > > echo 'Contents of document "' . $feed->entries[0]->title . '":<hr>'; > echo "<pre>$fileContents</pre>"; > > function download($client, $url, $format=null) { > $token = $client->getHttpClient()->getAuthSubToken(); > $opts = array( > 'http' => array( > 'method' => "GET", > 'header' => "GData-Version: 2.0\r\n". > "Authorization: AuthSub token=\"$token\"\r\n" > ) > ); > $context = stream_context_create($opts); > > if ($url != null) { > $url = $url . "&exportFormat=$format"; > } > > return file_get_contents($url, false, $context); > > } > > Eric > > On Jul 14, 7:56 pm, infinitas <john.cia...@gmail.com> wrote: > > > $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; > > $httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, > > $service); > > $gdClient = new Zend_Gdata_Docs($httpClient); > > echo file_get_contents("http://docs.google.com/View?docID={$id} > > &revision=_latest&hgd=1"); > > > More or less, this is what I have *working* which raises three > > questions. > > > 1. Is fopen/curl/file_get_contents the accepted method of getting the > > content or is there an API call I should be using? > > 2. Does the document HAVE to be "published" for it to work? > > 3. Is it necessary to have the "Google Docs -- Web word processing, > > presentations and spreadsheets." in the footer? (I am assuming number > > one is "no" and the correct method would probably have an option for > > this). > > > On Jul 14, 12:11 am, Eric Bidelman <api.e...@google.com> wrote: > > > > What have you tried? > > > > On Mon, Jul 13, 2009 at 7:53 PM, infinitas <john.cia...@gmail.com> wrote: > > > > > I am using the PHP Zend_Gdata API. I have successfully been able to > > > > retrieve a list of my documents and search through my documents, but I > > > > have not been able to retrieve the actual content inside a document. > > > > Could someone please point me in the right direction? > > > > > Thanks > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Docs Data APIs" group. To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com To unsubscribe from this group, send email to google-docs-data-apis+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Docs-Data-APIs?hl=en -~----------~----~----~----~------~----~------~--~---