繁体   English   中英

如何使用 Google 日历 API 在 C# 中的 Google Meet 中创建带有视频会议的活动?

[英]How to create event with videoconference in Google Meet in C# using Google Calendar API?

嗯..我正在尝试这段代码来创建一个事件

            CalendarService service;
            GoogleCredential credential;

            try
            {
                string[] scopes = new string[] { CalendarService.Scope.Calendar };
                using (var stream = new FileStream(@"C:\Prueba\meet.json", FileMode.Open, FileAccess.Read))
                {
                    credential = GoogleCredential.FromStream(stream)
                    .CreateScoped(scopes);
                }
                service = new CalendarService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential
                });


                Event calendarEvent = new Event();
                DateTime start = DateTime.Now;
                calendarEvent.Kind = "";
                calendarEvent.Summary = "prueba";
                calendarEvent.Status = "confirmed";
                calendarEvent.Visibility = "public";
                calendarEvent.Description = "prueba";

                calendarEvent.Creator = new Event.CreatorData
                {
                    Email = "email@example.com", //email@example.com
                    Self = true
                };

                calendarEvent.Organizer = new Event.OrganizerData
                {
                    Email = "email@example.com",
                    Self = true
                };

                calendarEvent.Start = new EventDateTime
                {
                    DateTime = start,
                    TimeZone = "America/Mexico_City"
                };

                calendarEvent.End = new EventDateTime
                {
                    DateTime = start.AddHours(1),
                    TimeZone = "America/Mexico_City"
                };

                calendarEvent.Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=1" };
                calendarEvent.Sequence = 0;
                calendarEvent.HangoutLink = "";

                calendarEvent.ConferenceData = new ConferenceData
                {
                    CreateRequest = new CreateConferenceRequest
                    {
                        RequestId = "1234abcdef",
                        ConferenceSolutionKey = new ConferenceSolutionKey
                        {
                            Type = "hangoutsMeet"
                        },
                        Status = new ConferenceRequestStatus
                        {
                            StatusCode = "success"
                        }
                    },
                    EntryPoints = new List<EntryPoint>
                    {
                        new EntryPoint
                        {
                            EntryPointType = "video",
                            Uri = "",
                            Label = ""
                        }
                    },
                    ConferenceSolution = new ConferenceSolution
                    {
                        Key = new ConferenceSolutionKey
                        {
                            Type = "hangoutsMeet"
                        },
                        Name = "Google Meet",
                        IconUri = ""
                    },
                    ConferenceId = ""
                };

                //calendarEvent.EventType = "default";


                EventsResource.InsertRequest request = service.Events.Insert(calendarEvent, "email@example.com");
                request.ConferenceDataVersion = 0;
                Event createEvent = request.Execute();
                string url = createEvent.HangoutLink;
            }
            catch (Exception ex)
            {

            }

源代码在这里

当我执行第 116 行时: Event createEvent = request.Execute(); 我收到此错误: Google.Apis.Requests.RequestError 会议类型值无效。 [400] 错误 [消息[无效的会议类型值。] 位置 [-] 原因 [无效] 域 [全局]

我不知道这个错误是什么意思,我错了 谁能帮我举个例子,使用来自 Google API 日历的类 C# 创建一个事件?

createRequestC# 库文档中所述:

需要conferenceSolution 和至少一个entryPoint,或者需要createRequest。

这意味着您应该使用CreateConferenceRequest ,因为这个会议是全新的(如果它已经存在,那么您可能希望将ConferenceSolutionEntryPoints一起使用)。 因此,只需删除ConferenceSolutionEntryPoints以仅保留CreateConferenceRequest ,如文档中指定的用于生成新会议并将其附加到事件中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM