我试图弄清楚是否已经插入了与iCal的交互,我可以使用的Google API,或者我需要自己动手并自己编写.
如果有人知道我可以看到的好资源可以帮助我实现,那也会很好.
我是RoR的新手,我一直试图学习它.我终于决定开始玩我自己的应用程序,而不仅仅是关注一本书.
任何有关此事的帮助将不胜感激.
谢谢!
查看Google Calendar gem for rails.它允许您在rails应用中显示用户的Google日历,并且他们有示例片段,展示如何将事件导出到Google日历:
require 'googlecalendar' g = GData.new g.login('REPLACE_WITH_YOUR_MAIL@gmail.com', 'REPLACE_WITH_YOUR_PASSWORD') event = { :title=>'title', :content=>'content', :author=>'pub.cog', :email=>'pub.cog@gmail.com', :where=>'Toulouse,France', :startTime=>'2007-06-06T15:00:00.000Z', :endTime=>'2007-06-06T17:00:00.000Z'} g.new_event(event)
对于iCal,使用iCalendar gem,然后您可以导出事件,如下所示:
require ‘icalendar’ class EventController < ApplicationController def export_events @event = Event.find(params[:id]) @calendar = Icalendar::Calendar.new event = Icalendar::Event.new event.start = @event.dt_time.strftime(”%Y%m%dT%H%M%S”) event.end = @event.dt_time.strftime(”%Y%m%dT%H%M%S”) event.summary = @event.summary event.description = @event.description event.location = @event.location @calendar.add event @calendar.publish headers['Content-Type'] = “text/calendar; charset=UTF-8? render_without_layout :text => @calendar.to_ical end end