2010-10-25 192 views
1

我希望对熟悉Google Calendar API的人来说,这样做相对容易一些,但已经做了一些搜索,但API并未给出答案!Google日历 - 从特定日历中获取活动

想象一下,Google帐户有3个日历,全部由该用户创建。

我试图从该用户的特定日历获取事件,使用.NET API谷歌,如下:

Calendar.userName = CalendarUserName; 
    Calendar.userPassword = CalendarPassword; 
    Calendar.feedUri = "https://www.google.com/calendar/feeds/default/private/full"; 

什么,给我的是所有事件的所有日历的饲料,这一切都很好,但我需要解析它们(大概有一种方法可以识别,但我也不知道)。

什么是理想的是我能够挑选并要求特定的日历,并且只能从那个日历中获得事件。

这可能吗?它只能使用magic-cookie请求吗?

感谢 邓肯

回答

2

你看过这个吗?

http://code.google.com/apis/calendar/data/2.0/reference.html#Event_feeds

这一个?

http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#RetrievingEvents

这是关键的部分,了解它,我想:

注意:这些代码片段显示 添加事件的默认日历 或特定用户的主 日历(将邮政地址 替换为POST URI中的“默认”字符串),但事件也可以添加到 非主要日历中。要做到这一点,您只需要日历ID ,它可以从 allcalendars提要中检索到,并且在 用户界面的日历设置页面中也显示为 。此ID再次用于Feed URI: https://www.google.com/calendar/feeds/id/private/full

http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#RetrievingCalendars

+0

所以,我要求应该是饲料:https://www.google.com/calendar/feeds/ /私营/满了吗?我的理解是,魔术饼干将在上面的私人部分....嗯,还是有点困惑!无论如何,我想我只会使用魔术饼干版本,因为这会让我获得我想要的日历。 – Duncan 2010-10-26 00:00:59

0
Dim singleUseToken As String = Request.getString("token") 

     Session("sessionToken") = AuthSubUtil.exchangeForSessionToken(singleUseToken, Nothing) 

     Dim authFactory As GAuthSubRequestFactory = New GAuthSubRequestFactory("cl", "LeaveCalendar") 
     authFactory.Token = Session("sessionToken").ToString 
     Dim service As Service = New Service("cl", authFactory.ApplicationName) 
     service.RequestFactory = authFactory 

     Dim query As New CalendarQuery() 
     query.Uri = New Uri("https://www.google.com/calendar/feeds/default/owncalendars/full") 
     Dim resultFeed As AtomFeed = CType(service.Query(query), AtomFeed) 

     For Each entry As AtomEntry In resultFeed.Entries 
      Response.Write("Your calendar:" & entry.Title.Text) 
      Response.Write("<br>") 
      Response.Write("<br>Calendar id " & entry.SelfUri.ToString.Substring(64)) 
     Next 

我试了一下凌动的东西,链接,但总是收到错误,异常。 我改变了代码豆蔻位,尤其是这2行:

1)昏暗resultFeed作为AtomFeed = CTYPE(service.Query(查询),AtomFeed)

2)对于每个条目作为AtomEntry在resultFeed。项

我希望它能帮助其他用户VB.NET