2010-10-25 191 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