如何从Google-Calendar事件中获取属性?

时间:2014-08-19 08:28:40

标签: c# .net google-api google-calendar-api

在过去的几天里,我试图从Google日历事件中读取属性

所以目前我只是想从我的日历中获取事件ID。

代码:

using System;
using Google.GData.Extensions;
using Google.GData.Calendar;

namespace ConsoleApplication1
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {

            EventQuery query = new EventQuery();
            query.Uri = new Uri("https://www.google.com/calendar/feeds/my@e-mail.com/public/basic");
            query.NumberToRetrieve = 10;
            query.StartTime = System.DateTime.Now;
            query.EndTime = System.DateTime.Today.AddDays(10);
            CalendarService service = new CalendarService(appName);
            service.setUserCredentials(userName, password);

            EventFeed calFeed = service.Query(query);

            foreach (EventEntry feedEntry in calFeed.Entries)
            {
                Console.WriteLine("Event ID: " + feedEntry.EventId);
                Console.ReadLine();
            }
        }
    }
}

我尝试feedEntry.Title.Text来获取标题...但它总是"忙碌"

所以我的问题是:

我可以从我的活动中获取信息吗?

2 个答案:

答案 0 :(得分:0)

答案是:

 query.Uri = new Uri("https://www.google.com/calendar/feeds/my@e-mail.com/public/basic");

必须是:

 query.Uri = new Uri("https://www.google.com/calendar/feeds/my@e-mail.com/private/full");

答案 1 :(得分:0)

您应该完全迁移这种方法。 Gdata是已弃用的Calendar API,将于11月关闭:http://googleappsdeveloper.blogspot.co.at/2014/07/upgrade-now-to-calendar-apiv3.html

使用Calendar API v3 https://developers.google.com/google-apps/calendar/

中的Events.List