duanma8207 2012-07-02 14:06
浏览 53
已采纳

Zend Google Docs API insertEntry导致空白文档

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).

  • 写回答

2条回答 默认 最新

  • dpdx51205 2012-07-12 22:29
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像