尝试将活动添加到 google 日历时出错

Getting error when trying to add event to google calendar

当用户尝试将事件添加到他们的 google 日历时,会发生此错误:We're sorry. There was a problem loading your calendar. Please try again in a few minutes. 我不确定我是否正在使用此方法进行操作?

Google URL

  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

老实说,我以前从未使用过它,但它正在崩溃。有人知道我可能做错了什么吗?

尝试使用日历 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}"