关注Google oAuth-1.我已经通过Client_ID&Secret_ID-2.交换该代码以获得Access Token-3.现在我要插入删除&在谷歌日历中搜索数据/事件,使用我可用的访问令牌而不是用户的信用信息。请告诉我我做错了什么。
获取错误:执行请求失败:http://www.google.com/calendar/feeds/imenmyself4u@gmail.com/private/full
有人能在这方面帮忙吗?
Uri oCalendarUri;
ExtendedProperty oExtendedProperty;
void Insert()
{
Google.GData.Calendar.EventEntry oEventEntry = new Google.GData.Calendar.EventEntry();
oEventEntry.Title.Text = "Test Calendar Entry From .Net";
oEventEntry.Content.Content =
"Hurrah!!! I posted my first Google calendar event through .Net";
Where oEventLocation = new Where();
oEventLocation.ValueString = "New Zealand";
oEventEntry.Locations.Add(oEventLocation);
When oEventTime = new When(new DateTime(2014, 9, 26, 09, 0, 0),
new DateTime(2014, 9, 26, 12 , 0, 0).AddHours(2));
oEventEntry.Times.Add(oEventTime);
oExtendedProperty = new ExtendedProperty();
oExtendedProperty.Name = "SynchronizationID";
oExtendedProperty.Value = Guid.NewGuid().ToString();
myValue = oExtendedProperty.Value;
oEventEntry.ExtensionElements.Add(oExtendedProperty);
CalendarService oCalendarService = GAuthenticate();
System.Net.ServicePointManager.Expect100Continue = false;
//Save Event
oCalendarService.Insert(oCalendarUri, oEventEntry);
}
private CalendarService GAuthenticate()
{
oCalendarUri = new Uri("http://www.google.com/calendar/feeds/" +
sGoogleUserName + "/private/full");
CalendarService oCalendarService = new CalendarService("CalendarSampleApp");
string token = Session["token"].ToString();
oCalendarService.SetAuthenticationToken(token);
return oCalendarService;
}
您正在使用的api已被弃用,将于今年11月关闭(https://developers.google.com/google-apps/calendar/v2/developers_guide_protocol)。请将代码更新到最新的API,您可以在这里找到迁移指南:https://developers.google.com/google-apps/calendar/migration