Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Documents List API - How to Publish a Document
    text
    copied!<p>I'm utterly lost as to how one can programmatically publish a Google Document (specifically a spreadsheet).</p> <p>I've read the Google Documents List API Protocol Guide and have found this:</p> <p><a href="http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#GettingRevisions" rel="nofollow">http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#GettingRevisions</a></p> <p>The next section of the article begins with 'Publishing documents by publishing a single revision' and this is where I found this example:</p> <pre><code>PUT /feeds/default/private/full/resource_id/revisions/revision_number GData-Version: 3.0 Authorization: &lt;your authorization header here&gt; Content-Length: 722 Content-Type: application/atom+xml &lt;entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd='http://schemas.google.com/g/2005' xmlns:docs="http://schemas.google.com/docs/2007" gd:etag="W/"DkIBR3st7ImA9WxNbF0o.""&gt; &lt;id&gt;https://docs.google.com/feeds/id/resource_id/revisions/1&lt;/id&gt; &lt;updated&gt;2009-08-17T04:22:10.440Z&lt;/updated&gt; &lt;app:edited xmlns:app="http://www.w3.org/2007/app"&gt;2009-08-06T03:25:07.799Z&lt;/app:edited&gt; &lt;title&gt;Revision 1&lt;/title&gt; &lt;content type="text/html" src="https://docs.google.com/feeds/download/documents/Export?docId=doc_id&amp;amp;revision=1"/&gt; &lt;link rel="alternate" type="text/html" href="https://docs.google.com/Doc?id=doc_id&amp;amp;revision=1"/&gt; &lt;link rel="self" type="application/atom+xml" href="https://docs.google.com/feeds/default/private/full/resource_id/revisions/1"/&gt; &lt;author&gt; &lt;name&gt;user&lt;/name&gt; &lt;email&gt;user@gmail.com&lt;/email&gt; &lt;/author&gt; &lt;docs:publish value="true"/&gt; &lt;docs:publishAuto value="false"/&gt; &lt;/entry&gt; </code></pre> <p>I have been retrieving document list feeds and CRUDing worksheets but I cannot get the publishing to work nor do I understand how it is supposed to work. My basic setup for establishing a connection to my feed and preparing the data to be PUT is as follows:</p> <pre><code>&lt;?php set_include_path($_SERVER['DOCUMENT_ROOT'].'/library/'); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader-&gt;setFallbackAutoloader(true); $theId = 'my-worksheet-id'; $user = "my-gmail-account-name"; $pass = "my-gmail-account-password"; $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata($client); $xml = "&lt;entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:docs='http://schemas.google.com/docs/2007' gd:etag='W/\"DkIBR3st7ImA9WxNbF0o.\"'&gt; &lt;id&gt;https://docs.google.com/feeds/id/spreadsheet:$theId/revisions/1&lt;/id&gt; &lt;updated&gt;2009-08-17T04:22:10.440Z&lt;/updated&gt; &lt;app:edited xmlns:app='http://www.w3.org/2007/app'&gt;2009-08-06T03:25:07.799Z&lt;/app:edited&gt; &lt;title&gt;Revision 1&lt;/title&gt; &lt;content type='text/html' src='https://docs.google.com/feeds/download/documents/Export?docId=$theId&amp;amp;revision=1'/&gt; &lt;link rel='alternate' type='text/html' href='https://docs.google.com/Doc?id=$theId&amp;amp;revision=1'/&gt; &lt;link rel='self' type='application/atom+xml' href='https://docs.google.com/feeds/default/private/full/spreadsheet:$theId/revisions/1'/&gt; &lt;author&gt; &lt;name&gt;$user&lt;/name&gt; &lt;email&gt;$user&lt;/email&gt; &lt;/author&gt; &lt;docs:publish value='true'/&gt; &lt;docs:publishAuto value='false'/&gt; &lt;/entry&gt;"; $putURL = "http://docs.google.com/feeds/default/private/full/spreadsheet:".$theId."/revisions/0"; $data = $service-&gt;put($xml, $putURL); ?&gt; </code></pre> <p>Which results in a</p> <pre><code>Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 Invalid request URI </code></pre> <p>Can someone help me out? Has anyone successfully published a Google Document programmatically?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload