1

我们的域(教育)有谷歌应用程序。在我们的学生数据库系统中,我们拥有所有班级信息。

我们想编写一个同步过程,强制所有教师和学生日历与谷歌日历同步。这一切似乎都很简单......减去所有“假设”,但这需要时间来弄清楚。

在尝试决定如何通过谷歌进行身份验证时,我目前正在碰壁。由于单个用户每天可以进行的通话量是有限的,因此我不能真正拥有一个管理员用户帐户来负责同步每个人。

有人可以告诉我应该采用哪个身份验证方向吗?我不需要用户登录,我只需要写入他们所有的日历。我听说过 2 腿 OAuth,但我对究竟什么是正确答案感到困惑,并且确实需要一些关于使用什么的指导。

非常感谢。

4

1 回答 1

0

以下是我用于类似项目的一些代码片段。我使用了 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

总之,我只是使用谷歌为 .net 框架提供的日历服务类。FstrEmail 只是与日历关联的电子邮件地址,而 FstrPassword 是常规的 google 密码。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

类似的过程可用于更新和删除条目。我用它来同步电子表格与多个谷歌日历,它工作正常。

于 2011-04-27T15:48:11.103 回答