【问题标题】:I'm not able to create a hangouts link or google meet link through google calendar API [closed]我无法通过 Google Calendar API 创建环聊链接或 Google Meet 链接 [关闭]
【发布时间】:2020-09-09 18:12:33
【问题描述】:

几天前,它正在“自动将 Google Meet 添加到我的日历活动”中。 突然,它在 Google Calendar API 中不起作用,“getHangoutLink()”返回“null”。

我该如何解决?帮我写一些代码。

提前致谢。

【问题讨论】:

    标签: java android calendar google-calendar-api google-meet


    【解决方案1】:

    使用以下代码。

    Event event = new Event()
            .setSummary(title)
            .setLocation(location)
            .setDescription(description);
    
    
    DateTime startDateTime = new DateTime( date +"T"+startTime+"+06:00" );//"2020-05-05T11:00:00+06:00");
    EventDateTime start = new EventDateTime()
            .setDateTime(startDateTime)
            .setTimeZone("Asia/Dhaka");
    event.setStart(start);
    
    DateTime endDateTime = new DateTime(date +"T"+endTime+"+06:00");//"2020-05-05T12:00:00+06:00");
    EventDateTime end = new EventDateTime()
            .setDateTime(endDateTime)
            .setTimeZone("Asia/Dhaka");
    event.setEnd(end);
    
    String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=1"};
    event.setRecurrence(Arrays.asList(recurrence));
    

    /* s1 = "abc@gmail.com"; s2 = "xyz@gmail.com";

    EventAttendee[] attendees = new EventAttendee[] {
            new EventAttendee().setEmail(s1),
            new EventAttendee().setEmail(s2),
    };*/
    
    
    
    EventAttendee attendees[];
    
    attendees = new EventAttendee[allAttendees.size()];
    
    for(int i=0; i<allAttendees.size(); i++){
       // System.out.println(allAttendees.get(i));
        attendees[i] = new EventAttendee().setEmail(allAttendees.get(i));
    }
    event.setAttendees(Arrays.asList(attendees));
    
    
    
    EventReminder[] reminderOverrides = new EventReminder[] {
            new EventReminder().setMethod("email").setMinutes(24 * 60),
            new EventReminder().setMethod("popup").setMinutes(10),
    };
    
    
    Event.Reminders reminders = new Event.Reminders()
            .setUseDefault(false)
            .setOverrides(Arrays.asList(reminderOverrides));
    event.setReminders(reminders);
    
    
    ConferenceSolutionKey conferenceSKey = new ConferenceSolutionKey();
    conferenceSKey.setType("hangoutsMeet"); // Non-G suite user
    CreateConferenceRequest createConferenceReq = new CreateConferenceRequest();
    createConferenceReq.setRequestId("3whatisup3"); // ID generated by you
    createConferenceReq.setConferenceSolutionKey(conferenceSKey);
    ConferenceData conferenceData = new ConferenceData();
    conferenceData.setCreateRequest(createConferenceReq);
    event.setConferenceData(conferenceData);
    
    String calendarId = "primary";
    
    try {
        event = service.events().insert(calendarId, event).setConferenceDataVersion(1).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
    
    System.out.printf("Event created: %s\n", event.getHtmlLink());
    System.out.printf("Hangout Link %s\n", event.getHangoutLink());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-08
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 2014-10-06
      相关资源
      最近更新 更多