Seva's notes

Wisdom, Awareness, Responsibility :)

Download a Google Document with Zend_GData API

with 3 comments

Today I’ve thought of a way of showing a private Google Document on a custom page with no need to authenticate. I was surprised that the issue was not covered in any documentation; I also didn’t succeed to find a quick solution on the Internet. Thus I’m sharing with you the solution using Zend_GData library, my dear friend, with hope to save your valuable time:

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, Zend_Gdata_Docs::AUTH_SERVICE_NAME);
$api = new Zend_Gdata_Docs($client);
$doc = $api->getDocument($docId);
$response = $client->request();
$html = $response->getBody();   

Voila! The $html variable now contains the clean and image/css/js safe content to use (including <HTML> tags)

Note: The code lacks exception handling for simplicity, so please keep that in mind and fulfill upon need.

Written by Seva

2010-02-01 (February 1) at 06:35:51

3 Responses

Subscribe to comments with RSS.

  1. thx fot this. find what i need 😉


    2011-10-02 (October 2) at 03:45:36

  2. do you think this can be made to download other files? It works fine for docx on my side, but anything such as powerpoints or pdf give me a “Moved Temporarily” message


    2012-06-16 (June 16) at 06:52:13

    • I think this method works only for files which have HTML representation.


      2012-06-16 (June 16) at 12:44:02

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: