以下是我用於類似項目的一些代碼片段。我使用了google api和.net框架,這比使用OAuth更容易。這些片段在Visual Basic中
Imports Google.GData
Imports Google.GData.Client
Imports Google.GData.Calendar
.....Various Property Fields for the class go here.....
Public Sub AddEvent()
Try
Dim theEvent As New EventEntry
Dim theCalendarService As CalendarService = New CalendarService(FProgID)
Dim theTime As New Extensions.When(FEventStartTime, FEventEndTime)
Dim theEntry As AtomEntry
If FAllDay = True Then
theTime.AllDay = True
Else
theTime.AllDay = False
End If
theEvent.Title.Text = FEventTitle
theEvent.Times.Add(theTime)
If Not FDescription = "" Then
theEvent.Content.Content = FDescription
End If
If Not FEventLocation = "" Then
Dim theLocation As New Extensions.Where
theLocation.ValueString = FEventLocation
theEvent.Locations.Add(theLocation)
End If
If Not FAuthor = "" Then
Dim theAuthor As New AtomPerson
theAuthor.Name = FAuthor
theEvent.Authors.Add(theAuthor)
End If
theCalendarService.setUserCredentials(FstrEmail, FstrPassword)
theEntry = theCalendarService.Insert(FURLNoCookie, theEvent)
FStatus = "Event added successfully to Google Calendar"
Catch ex As Exception
FStatus = "Failed: Event was added to Job List, but not Google Calendar"
End Try
End Sub
總之,我只是使用Google提供的Calendar服務類來提供.net框架。 FstrEmail只是與日曆關聯的電子郵件地址,FstrPassword是普通的谷歌密碼。 FURLNoCookie實際上是您指定要傳送的日曆的位置。這只是日曆的XML專用共享URL(從日曆設置>私人地址獲取)。當你第一次從日曆中得到這個URL會是這個樣子
http://www.google.com/calendar/feeds/somebody%40gmail.com/private-188ba1932aa23d4a64ag712db232bfe8b/basic
修改它看起來像這樣
http://www.google.com/calendar/feeds/somebody%40gmail.com/private/full
一個類似的過程可用於更新和刪除條目。我用它來同步電子表格與多個谷歌日曆,它工作正常。
是的,我也在考慮這個問題,但是由於一天的要求太多,我想我最終會陷入潛在的障礙。我們正在尋找一個簡單的10-15k不同的活動,以便每天同步。你有沒有遇到麻煩? – wilbbe01 2011-04-27 16:28:09
我沒有遇到任何問題。但是,我的負載在高負載下從未經過負載測試。我所做的最多的是每天約一百人。 – ThinkerIV 2011-04-27 18:10:10