谷歌日历API asp.net C# [英] google calendar api asp.net c#
问题描述
我创建一个新的日历测试,我用这个code
i create a new calendar "test" and i use this code
public static CalendarService GetService(string applicationName, string userName, string password)
{
CalendarService service = new CalendarService(applicationName);
service.setUserCredentials(userName, password);
return service;
}
public static void AddEvent(CalendarService service, string title, string contents, string location, DateTime startTime, DateTime endTime)
{
Google.GData.Calendar.EventEntry entry = new Google.GData.Calendar.EventEntry();
// Set the title and content of the entry.
entry.Title.Text = title;
entry.Content.Content = contents;
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = location;
entry.Locations.Add(eventLocation);
When eventTime = new When(startTime, endTime);
entry.Times.Add(eventTime);
Uri postUri = new Uri("https://www.google.com/calendar/feeds/test/private/full");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);
}
AddEvent(GetService("regis-test", vUserName, vPassword), "title", "test", "Sibiu", DateTime.Now, DateTime.Now.AddHours(4));
什么是错的? becouse这个code不添加事件测试日历他添加到默认
what is wrong ? becouse this code do not add event to the test calendar he add to the default
推荐答案
您需要修改乌里以反映日历ID。
You need to modify the Uri to reflect the calendar ID.
我建立了我的Gmail帐户的测试日程,并能够使用以下URI我的日历创建日历事件:
I have created a test calendar on my gmail account and was able to create a calendar event using the following URI for my calendar:
Uri postUri = new Uri("https://www.google.com/calendar/feeds/hsi9s9tlvgkugbub8r42kv9ugk@group.calendar.google.com/private/full");
要查找日历ID为您的测试日历,你需要做到以下几点:
To find the calendar ID for your test calendar you need to do the following:
选择在我的日历和preSS设置在左边的菜单测试的日历。
Select your test calendar in the left menu under "My calendars" and press settings.
然后选择您的日历:
在你看到日历网址下你的日历ID下一个画面:
In the next screen you see your calendar ID under Calendar Address:
使用的ID为您的网址:
Use the id for your Uri:
Uri postUri = new Uri("https://www.google.com/calendar/feeds/hsi9s9tlvgkugbub8r42kv9ugk@group.calendar.google.com/private/full");
下面是通过测试日历C#code创建的日历事件的截图:
Here is a screenshot of a calendar event created through C# code on the test calendar:
这篇关于谷歌日历API asp.net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!