이 코드를 사용하는 자바 코드입니다. 방 (리소스 Google 캘린더 API를 사용하여 방이 추가됨) 이벤트가 방 A로 완전히 생성 된 이벤트입니다. 그러나 체크인 할 때 Google 캘린더를 사용하여 방을 사용할 수 있는지 확인하십시오. 나는 그것이 표시되지 않아야하거나 파업으로 보여 주어야한다고 기대할 수 있습니다. 어느 한 사람이이 문제에 대한 해결책을 말해 줄 수 있습니까? 나는 실수를하고 있습니다.Google 캘린더를 사용하여 회의실을 차단할 수 없습니다. Api
public class CalendarQuickstart {
private static final String APPLICATION_NAME = "API Quickstart";
private static final java.io.File DATA_STORE_DIR = new java.io.File(System.getProperty("user.home"),
".credentials/calendar-java-quickstart");
private static FileDataStoreFactory DATA_STORE_FACTORY;
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
private static HttpTransport HTTP_TRANSPORT;
private static final List <String> SCOPES = Arrays.asList(CalendarScopes.CALENDAR);
static {
try {
HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
public static Credential authorize() throws IOException {
// Load client secrets.
/*InputStream in = CalendarQuickstart.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).setAccessType("offline").build();
Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
System.out.println("Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
return credential;*/
Credential credential = GoogleCredential.fromStream(CalendarQuickstart.class.getResourceAsStream("/client_secret.json"))
.createScoped(SCOPES);
return credential;
}
public static com.google.api.services.calendar.Calendar getCalendarService() throws IOException {
Credential credential = authorize();
return new com.google.api.services.calendar.Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME).build();
}
public static void createEvent() throws IOException {
Event event = new Event().setSummary("Google I/O 2015")
.setDescription("A chance to hear more about Google's developer products.");
DateTime startDateTime = new DateTime("2017-02-27T22:00:00+05:30");
EventDateTime start = new EventDateTime().setDateTime(startDateTime).setTimeZone("Asia/Kolkata");
event.setStart(start);
DateTime endDateTime = new DateTime("2017-02-27T23:00:00+05:30");
EventDateTime end = new EventDateTime().setDateTime(endDateTime).setTimeZone("Asia/Kolkata");
event.setEnd(end);
EventAttendee[] attendees = new EventAttendee[] {
new EventAttendee().setEmail("[email protected]"),
new EventAttendee().setEmail("[email protected]"), new EventAttendee().
setEmail("[email protected]m").setResponseStatus("accepted")
};
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);
String calendarId = "primary";
event = getCalendarService().events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getId());
}
public static void updateEvent() throws IOException {
Event event = getCalendarService().events().get("primary", "3k90eohao76bk3vlgs8k5is6h0").execute();
event.setSummary("Appointment at Somewhere");
// Update the event
Event updatedEvent = getCalendarService().events().update("primary", event.getId(), event).execute();
System.out.println(updatedEvent.getUpdated());
}
public static void main(String[] args) throws IOException {
com.google.api.services.calendar.Calendar service = getCalendarService();
DateTime now = new DateTime(System.currentTimeMillis());
Events events = service.events().list("primary").setMaxResults(10).setTimeMin(now).setOrderBy("startTime")
.setSingleEvents(true).execute();
List <Event> items = events.getItems();
if (items.size() == 0) {
System.out.println("No upcoming events found.");
} else {
System.out.println("\nUpcoming events");
for (Event event: items) {
DateTime start = event.getStart().getDateTime();
if (start == null) {
start = event.getStart().getDate();
}
System.out.printf("%s (%s)\n", event.getSummary(), start);
}
}
createEvent();
}
서비스 계정 또는 Oauth2와 같은 종류의 Java를 oauth2와 같이 사용하고 계십니까? – DaImTo
예 서비스 계정 @DalmTo –
@DalmTo 어떤 해결책이든지 제안 해주세요. 해결 방법은 없는지 제안 해주세요. 그것은 오랜 시간부터 –