尝试将事件添加到Google日历时出错

时间:2017-03-06 20:07:30

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

当用户尝试向Google日历添加事件时,会出现以下错误:We're sorry. There was a problem loading your calendar. Please try again in a few minutes.我不确定这是否是我在此方法中所做的事情?

Google网址

  def google_url
    "https://www.google.com/calendar/render?action=TEMPLATE\
    &text=#{CGI.escape @event.name}\
    &dates=#{@event.starts_at.strftime('%Y%m%dT%H%M%S')}/\
    #{@event.ends_at.strftime('%Y%m%dT%H%M%S')}\
    &ctz=#{google_time_zone}\
    &details=For+details,+link+here:+#{@event_url}\
    &location=#{CGI.escape @event.location.name}+\
    #{CGI.escape(@event.location.address)}".gsub(/\s*/, "")
  end

我以前从来没有使用过这个,但它已经破裂了。有人知道我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

如果与您合作,请尝试使用日历API的Events: insert。您可以在此处使用“试用”部分在日历中创建日历活动。

您还可以在此处关注如何创建活动的Ruby code example

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},
    ],
  },
}

result = client.insert_event('primary', event)
puts "Event created: #{result.html_link}"