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

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路