gpt4 book ai didi

ruby - Google Calendar V3 Ruby API 插入事件

转载 作者:太空宇宙 更新时间:2023-11-03 17:21:36 24 4
gpt4 key购买 nike

我正在使用 https://developers.google.com/google-apps/calendar/v3/reference/events/insert 中的示例

event = Google::Apis::CalendarV3::Event.new{
summary:'Google I/O 2015',
location:'800 Howard St., San Francisco, CA 94103',
description:'A chance to hear more about Google\'s developer products.',
start: {
date_time: '2015-05-28T09:00:00-07:00',
time_zone:'America/Los_Angeles',
},
end: {
date_time:'2015-05-28T17:00:00-07:00',
time_zone:'America/Los_Angeles',
}
}

result = service.insert_event(calendar_id, event)

但是,我得到了错误:

wwtlf:~/workspace $ ruby test.rb 
/usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:202:in `check_status': required: Missing end time. (Google::Apis::ClientError)
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/api_command.rb:103:in `check_status'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:170:in `process_response'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:275:in `execute_once'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:107:in `block (2 levels) in execute'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:104:in `block in execute'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
from /usr/local/rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/http_command.rb:96:in `execute'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/lib/google/apis/core/base_service.rb:267:in `execute_or_queue_command'
from /usr/local/rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.1/generated/google/apis/calendar_v3/service.rb:1207:in `insert_event'

示例中的事件对象有什么问题?我尝试使用 dateTime 代替 date_time,但错误是一样的。

更新:原始示例:

event = Google::Apis::CalendarV3::Event.new{
summary: 'Google I/O 2015',
location: '800 Howard St., San Francisco, CA 94103',
description: 'A chance to hear more about Google\'s developer products.',
start: {
date_time: '2015-05-28T09:00:00-07:00',
time_zone: 'America/Los_Angeles',
},
end: {
date_time: '2015-05-28T17:00:00-07:00',
time_zone: 'America/Los_Angeles',
},
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
{email: 'lpage@example.com'},
{email: 'sbrin@example.com'},
],
reminders: {
use_default: false,
overrides: [
{method' => 'email', 'minutes: 24 * 60},
{method' => 'popup', 'minutes: 10},
],
},
}

enter image description here显然,有很多语法错误。(missed ')method' => 'popup', 'minutes(missed '): 10

所以,我决定修改它:

event = Google::Apis::CalendarV3::Event.new{
summary:'Google I/O 2015',
location:'800 Howard St., San Francisco, CA 94103',
description:'A chance to hear more about Google\'s developer products.',
start: {
date_time:'2015-05-28T09:00:00-07:00',
time_zone:'America/Los_Angeles',
},
end: {
date_time:'2015-05-28T17:00:00-07:00',
time_zone:'America/Los_Angeles',
},
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
{email: 'lpage@example.com'},
{email: 'sbrin@example.com'},
],
reminders: {
use_default: false,
overrides: [
{'method' => 'email', 'minutes'=> 24 * 60},
{'method' => 'popup', 'minutes'=> 10},
],
}
}

但是,我仍然得到 http_command.rb:202:in `check_status': required: Missing end time。 (谷歌::Apis::ClientError)

最佳答案

对我来说,atm,使用这个语法:

Google::Apis::CalendarV3::Event.new({
:summary => 'event title',
:location => 'event address',
:description => 'event description',
:start => {
:date_time => 'event start time in rfc3339'
},
:end => {
:date_time => 'event end time in rfc 3339'
}
})

关于ruby - Google Calendar V3 Ruby API 插入事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35033182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com