使用 C# 从 Google 日历 API 获取数据
Fetching Data From Google Calendar API with C#
我想从 C# 应用程序中使用 Google 日历 API 从 Google 日历获取数据。
我有我用户的电子邮件和密码,所以我不需要 OAuth 或其他东西,我正在关注 this guide。
这是一个示例代码:
FeedQuery query = new FeedQuery();
Service service = new Service("cal","company-app-v1.0");
service.setUserCredentials("fname.lname@gmail.com", "passphrase");
query.Uri = new Uri("http://www.google.com/calendar/feeds/fname.lname@gmail.com/private/full");
AtomFeed calFeed = service.Query(query);
System.Console.WriteLine("Start-------------");
System.Console.WriteLine(calFeed.Entries.Count);
System.Console.WriteLine("Finish-------------");
我不明白的是,我必须在服务构造函数或开发人员控制台中指定服务名称和应用程序名称吗??
我错过了什么?
您正在引用的页面是 2012 年 8 月 13 日 .net client library. It will not work with the current version of the Google .net client library nor will it work with the current version of the Google Calendar API。
无法使用登录名和密码访问 Google 日历,您必须按照此处所述使用开放式身份验证:Authorizing Requests to the Google Calendar API
Every request your application sends to the Google Calendar API must
include an authorization token. The token also identifies your
application to Google.
Your application must use OAuth 2.0 to authorize requests. No other
authorization protocols are supported. If your application uses
Google+ Sign-In, some aspects of authorization are handled for you.
我想从 C# 应用程序中使用 Google 日历 API 从 Google 日历获取数据。
我有我用户的电子邮件和密码,所以我不需要 OAuth 或其他东西,我正在关注 this guide。
这是一个示例代码:
FeedQuery query = new FeedQuery();
Service service = new Service("cal","company-app-v1.0");
service.setUserCredentials("fname.lname@gmail.com", "passphrase");
query.Uri = new Uri("http://www.google.com/calendar/feeds/fname.lname@gmail.com/private/full");
AtomFeed calFeed = service.Query(query);
System.Console.WriteLine("Start-------------");
System.Console.WriteLine(calFeed.Entries.Count);
System.Console.WriteLine("Finish-------------");
我不明白的是,我必须在服务构造函数或开发人员控制台中指定服务名称和应用程序名称吗??
我错过了什么?
您正在引用的页面是 2012 年 8 月 13 日 .net client library. It will not work with the current version of the Google .net client library nor will it work with the current version of the Google Calendar API。
无法使用登录名和密码访问 Google 日历,您必须按照此处所述使用开放式身份验证:Authorizing Requests to the Google Calendar API
Every request your application sends to the Google Calendar API must include an authorization token. The token also identifies your application to Google.
Your application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported. If your application uses Google+ Sign-In, some aspects of authorization are handled for you.