如何使用gdata gem / api创建文档?

时间:2012-06-20 18:42:55

标签: ruby api gdata

我可以创建.. 某些东西 ...但我在我的帐户的网页浏览中看不到它

require "gdata"
require "awesome_print"
require "nokogiri"


@client = GData::Client::DocList.new
@client.clientlogin('me', "mypass")

def post_doc
  # Return documents the authenticated user owns
  feed = @client.get('https://docs.google.com/feeds/documents/private/full/-/mine').to_xml
  entry = feed.elements['entry']  # first <atom:entry>

  acl_entry = <<-EOF
  <entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'>
    <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/acl/2007#accessRule'/>
    <title>Testing Ruby GData gem</title>
    <gAcl:role value='writer'/>
    <gAcl:scope type='user' value='idk@example.com'/>
  </entry>
  EOF

  # Regex the document id out from the full <atom:id>.
  # http://docs.google.com/feeds/documents/private/full/document%3Adfrk14g25fdsdwf -> document%3Adfrk14g25fdsdwf
  ap entry.elements['id']
  doc_id = entry.elements['id'].text[/full\/(.*%3[aA].*)$/, 1]
  response = @client.post("https://docs.google.com/feeds/acl/private/full/#{doc_id}", acl_entry)

end

如果我更改了gAcl:scope type ='user'字段的值,我似乎只能上传文档。

在我的Google帐户上,文档已经消失并被谷歌驱动器取代,这会有问题吗?

另外,是否有条目某处的字段列表,所以我可以指定我要创建的文档的正文?

0 个答案:

没有答案