简体   繁体   English

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

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

Well.. I'm trying this code to create an Event嗯..我正在尝试这段代码来创建一个事件

            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)
            {

            }

The source code is here源代码在这里

When I execute the line 116: Event createEvent = request.Execute();当我执行第 116 行时: Event createEvent = request.Execute(); I get this error: Google.Apis.Requests.RequestError Invalid conference type value.我收到此错误: Google.Apis.Requests.RequestError 会议类型值无效。 [400] Errors [Message[Invalid conference type value.] Location[ - ] Reason[invalid] Domain[global] [400] 错误 [消息[无效的会议类型值。] 位置 [-] 原因 [无效] 域 [全局]

I don't know what means this error o with line I wrong Could anyone help me with an example to create an event using classes C# from Google API Calendar?我不知道这个错误是什么意思,我错了 谁能帮我举个例子,使用来自 Google API 日历的类 C# 创建一个事件?

As described in the C# library documentation for createRequest :createRequestC# 库文档中所述:

Either conferenceSolution and at least one entryPoint, or createRequest is required.需要conferenceSolution 和至少一个entryPoint,或者需要createRequest。

This means that you should use only CreateConferenceRequest as this conference is brand new (if it already existed then you would be wanting to use ConferenceSolution along with EntryPoints ).这意味着您应该使用CreateConferenceRequest ,因为这个会议是全新的(如果它已经存在,那么您可能希望将ConferenceSolutionEntryPoints一起使用)。 Therefore, simply remove ConferenceSolution and EntryPoints to leave just CreateConferenceRequest which as specified in the documentation is used for generating a new conference and attach it to the event.因此,只需删除ConferenceSolutionEntryPoints以仅保留CreateConferenceRequest ,如文档中指定的用于生成新会议并将其附加到事件中。

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

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