Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Visual Studio连接到google calendar的API?(C)_C#_Google Calendar Api - Fatal编程技术网

C# 如何使用Visual Studio连接到google calendar的API?(C)

C# 如何使用Visual Studio连接到google calendar的API?(C),c#,google-calendar-api,C#,Google Calendar Api,我花了比我想承认的更多的时间来研究这个话题,但是说明书对我来说非常复杂。我正在开发一个带有日历GUI的程序,用户可以在其中选择一天,并键入当天可能发生的事件。完成后,我希望能够将用户的数据导入到我创建的谷歌日历中。我该怎么做?如果可以的话,我会非常感谢你给我一个简单的答案,因为我是学生,不是专业人士。谢谢大家! 谷歌有一个很好的解决方案 有一些,你可以找到 您可以找到。我能够按照Google日历API将Google日历集成添加到ASP.NET MVC应用程序中 基本上,您需要从下载JSON或P1

我花了比我想承认的更多的时间来研究这个话题,但是说明书对我来说非常复杂。我正在开发一个带有日历GUI的程序,用户可以在其中选择一天,并键入当天可能发生的事件。完成后,我希望能够将用户的数据导入到我创建的谷歌日历中。我该怎么做?如果可以的话,我会非常感谢你给我一个简单的答案,因为我是学生,不是专业人士。谢谢大家!

谷歌有一个很好的解决方案

有一些,你可以找到


您可以找到。

我能够按照Google日历API将Google日历集成添加到ASP.NET MVC应用程序中

基本上,您需要从下载JSON或P12身份验证文件,并使用它创建凭据:

using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
   string credPath = @"/location/to/store/credentials"
   UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
   GoogleClientSecrets.Load(stream).Secrets,
   CalendarService.Scope.Calendar,
   "user",
   CancellationToken.None,
   new FileDataStore(credPath, true)).Result;
}
使用开发人员控制台中的默认设置,每次需要新用户的权限时,您都会启动一个身份验证弹出窗口。如果他们在该屏幕中授予您权限,请使用凭据授权CalendarService对象:

然后,该服务将允许您为您当前进行身份验证的用户执行创建/读取/更新/删除请求:

Event newEvent = new Event()
{
    Summary = "new event",
    Start = new EventDateTime()
    {
        DateTime = DateTime.Parse("2016-07-11T09:00:00"),
        TimeZone = "America/Los_Angeles"
    },
    End = new EventDateTime()
    {
        DateTime = DateTime.Parse("2016-07-11T10:00:00"),
        TimeZone = "America/Los_Angeles"
    }
};

Event createdEvent = service.Events.Insert(newEvent, "primary").Execute();

您可以在中找到关于不同Google日历对象可用事件的更多信息,以及关于.NET包装器的更多信息,尽管.NET示例并不完整;你最好看这么多。您可以从应用程序中的任何位置创建这些对象

你试过什么了吗?如果你有一个尝试,不管它有多难看,发布它并提出具体问题。我在“你有什么问题?”上找到了C代码,这非常有帮助,但是这些说明是针对基于控制台的应用程序的,我正在使用windows窗体应用程序。有没有一种方法可以让我的GUI工作?
Event newEvent = new Event()
{
    Summary = "new event",
    Start = new EventDateTime()
    {
        DateTime = DateTime.Parse("2016-07-11T09:00:00"),
        TimeZone = "America/Los_Angeles"
    },
    End = new EventDateTime()
    {
        DateTime = DateTime.Parse("2016-07-11T10:00:00"),
        TimeZone = "America/Los_Angeles"
    }
};

Event createdEvent = service.Events.Insert(newEvent, "primary").Execute();