Reputation: 195
Im trying to simply create a new document using the Zend Google Docs API's insertEntry() function, but even though I am correctly setting the content, it always results in a blank document being added to my Google docs account.
I have followed the documentation found here http://framework.zend.com/manual/en/zend.gdata.introduction.html#zend.gdata.introduction.post (it might help to take a look at that the "Posting Entries to Google Servers" code example).
And I am using this code which is called within my class:
public function insertData() {
$gData = new Zend_Gdata($this->client);
$gCategory = new Zend_Gdata_App_Extension_Category('http://schemas.google.com/docs/2007#document', Zend_Gdata_Docs::DOCUMENTS_CATEGORY_SCHEMA);
$newEntry = $gData->newEntry();
$newEntry->category = (array($gCategory));
$newTitle = $gData->newTitle('Test');
$newContent = $gData->newContent('Testing new entry');
$newContent->setType('text');
$newEntry->title = $newTitle;
$newEntry->content = $newContent;
return $gData->insertEntry($newEntry, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
}
The title is correctly set, and shows correctly as "Test" in Google Docs, however the content is always blank.
I have tryed everything.. anyone have any ideas where the problem is?
Thanks.
UPDATE: It might help to know that the code posted on that documentation does not work as is (it is probably outdated). If you run that code it gives a "category required" error, revising the code to add a category requires a "category schema" from Google, which is a URL like "http://schemas.google.com/docs/2007#document".
On the Google docs API page https://developers.google.com/google-apps/documents-list/#creating_or_uploading_text_documents it states that this schema is: "To create a new, empty text document".. So this may be the issue.. however, I could not find a schema URL for creating a document from existing content (ie. not a empty document).
Upvotes: 1
Views: 266
Reputation: 195
Yes, I have to use the upload file method. It turns out that a method for direct data insertion isnt actually supported yet. I wish the API documentation stated this fact clearly...
Upvotes: 0
Reputation: 319
Could you use the uploadFile method in Zend_Gdata_Docs? You could upload a txt file that contains the default content you would like to see in the google doc.
Upvotes: 1