我无法通过谷歌日历 API 创建 Hangouts 链接或 Google Meet 链接。

huangapple go评论74阅读模式
英文:

I'm not able to create a hangouts link or google meet link through google calendar API

问题

几天前,"自动将Google Meet添加到我的日历事件中"还在工作。
突然间,在Google日历API中不再工作,"getHangoutLink()"返回"null"。

我该如何修复它?请帮我提供一些代码。

提前致谢。

英文:

A few days ago , it was working the "Automatically add Google Meet to my calendar events".
Suddenly, It has not worked in Google Calendar API and the "getHangoutLink()" returns "null".

How can I fix it? Help me with some codes.

Thanks in advance.

答案1

得分: 1

使用以下代码。

Event event = new Event()
        .setSummary(title)
        .setLocation(location)
        .setDescription(description);

DateTime startDateTime = new DateTime(date + "T" + startTime + "+06:00");
EventDateTime start = new EventDateTime()
        .setDateTime(startDateTime)
        .setTimeZone("Asia/Dhaka");
event.setStart(start);

DateTime endDateTime = new DateTime(date + "T" + endTime + "+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));

EventAttendee attendees[];

attendees = new EventAttendee[allAttendees.size()];

for(int i=0; i<allAttendees.size(); 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");
CreateConferenceRequest createConferenceReq = new CreateConferenceRequest();
createConferenceReq.setRequestId("3whatisup3");
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());
英文:

Use the following code.

Event event = new Event()
.setSummary(title)
.setLocation(location)
.setDescription(description);
DateTime startDateTime = new DateTime( date +&quot;T&quot;+startTime+&quot;+06:00&quot; );//&quot;2020-05-05T11:00:00+06:00&quot;);
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone(&quot;Asia/Dhaka&quot;);
event.setStart(start);
DateTime endDateTime = new DateTime(date +&quot;T&quot;+endTime+&quot;+06:00&quot;);//&quot;2020-05-05T12:00:00+06:00&quot;);
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone(&quot;Asia/Dhaka&quot;);
event.setEnd(end);
String[] recurrence = new String[] {&quot;RRULE:FREQ=DAILY;COUNT=1&quot;};
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&lt;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(&quot;email&quot;).setMinutes(24 * 60),
new EventReminder().setMethod(&quot;popup&quot;).setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);
ConferenceSolutionKey conferenceSKey = new ConferenceSolutionKey();
conferenceSKey.setType(&quot;hangoutsMeet&quot;); // Non-G suite user
CreateConferenceRequest createConferenceReq = new CreateConferenceRequest();
createConferenceReq.setRequestId(&quot;3whatisup3&quot;); // ID generated by you
createConferenceReq.setConferenceSolutionKey(conferenceSKey);
ConferenceData conferenceData = new ConferenceData();
conferenceData.setCreateRequest(createConferenceReq);
event.setConferenceData(conferenceData);
String calendarId = &quot;primary&quot;;
try {
event = service.events().insert(calendarId, event).setConferenceDataVersion(1).execute();
} catch (IOException e) {
e.printStackTrace();
}
System.out.printf(&quot;Event created: %s\n&quot;, event.getHtmlLink());
System.out.printf(&quot;Hangout Link %s\n&quot;, event.getHangoutLink());

huangapple
  • 本文由 发表于 2020年9月10日 02:12:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/63817296.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定