相关疑难解决方法(0)

Google Calendar API,只需知道他们的电子邮件地址即可向某人的日历添加活动

我已经下载了Google.Apis名称空间:

using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
Run Code Online (Sandbox Code Playgroud)

我花了一整天的时间在网上查看.NET示例,了解如何通过了解他们的电子邮件地址将事件添加到某人日历中.

我尝试了下面的代码,但它会带来错误,很明显它不会起作用:

Public void Method(string email, string text)
{
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
                {
                    ClientId = "CLIENTID",
                    ClientSecret = "CLIENTSECRET",
                },
                new[] { CalendarService.Scope.Calendar },
                "user",
                CancellationToken.None).Result;

   // Create the service.
   var service = new CalendarService(new BaseClientService.Initializer()
   {
                HttpClientInitializer = credential,
                ApplicationName = "Calendar API Sample",
   });


    Event event1 = new Event()
    {
      Summary = "Something",
      Location = "Somewhere",
      Start = new EventDateTime() {
          DateTime = DateTime.Now,
          TimeZone = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net api calendar google-api

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

api ×1

asp.net ×1

c# ×1

calendar ×1

google-api ×1