如何获取和编辑Google日历活动?轨道

时间:2013-07-08 09:34:33

标签: ruby-on-rails ruby google-calendar-api google-api-client

我有这段代码:

client = Google::APIClient.new

oauth_yaml = YAML.load_file('lib/.google-api.yaml')
client = Google::APIClient.new
client.authorization.client_id = oauth_yaml["client_id"]
client.authorization.client_secret = oauth_yaml["client_secret"]
client.authorization.scope = oauth_yaml["scope"]
client.authorization.refresh_token = oauth_yaml["refresh_token"]
client.authorization.access_token = oauth_yaml["access_token"]

if client.authorization.refresh_token && client.authorization.expired?
  client.authorization.fetch_access_token!
end

service = client.discovered_api('calendar', 'v3')

result = client.execute(:api_method => service.settings.list)

它正在工作:)但是,有人可以给我一个示例或链接向我展示:) 如何获取用户的事件并更新它们?

rails -v
Rails 3.2.13

ruby -v
ruby 1.9.3p327 (2012-11-10) [x86_64-darwin12.2.0]

我的Gemfile:

gem 'google-api-client'
gem 'googlecalendar'
gem 'gdata'
gem 'sinatra'
gem 'logger'
gem 'gdata_19'

非常感谢。

1 个答案:

答案 0 :(得分:2)

我使用了这个gem,它运行良好。

但它不使用Google API,只需使用Gmail帐户和密码登录并解析其响应即可。

所以我想这个宝石对你有好处。无论如何,试试吧。