Search code examples
phpzend-frameworkgdata-apigoogle-docs-apizend-gdata

Get a link to a Google Doc with Zend


Hey there - I'm using Zend Framework with Gdata to handle the Google Docs API. I've got it modified to use V3 so we can upload and manage pdf's from a web interface. We have a custom class gDataClient that sets up the Gdata_Docs service, Gdata_ClientLogin, and creates a new Gdata_Docs object.

On the page I'm working with, here's the relevant code:

$gDoc = & new gDataClient($agentGid, $agentGpw);
$something = $gDoc->GetDoc('mydocID','pdf');
print_r($something->content->src);

This generates a direct link to the document, but when I click it I get a 401 (Authentication Required) even though I've already created and authenticated the client.

Any ideas?


Solution

  • Okay, so the problem turned out to be dueling logins. A Gmail account automatically has a Google Account attached to it, but a Google Apps for Domains account does not. The link generated directed to docs.google.com/documentLink, which my Gmail account is authenticated for. The document in question is marked Private, so I couldn't view it. I ended up manually building the link based on Google App domain and docID - docs.google.com/a/myDomain.com/viewer?options=stuff&srcid=docID

    This will work fine for our situation, as everyone using the system will have an account at myDomain.com and those credentials in the DB - I'm not sure what the workaround would be to allow users to use standard Gmail or standalone Google accounts.