简体   繁体   中英

Events from database show to google calendar


I am developing an app, which works like a booking system. The main-component is a calendar which shows created events, which are stored in PostgreSQL database. My challenge now, is to show all the events from database to the admin´s google calendar. When the admin opens his google calendar, he only has rights to see the events, but not to edit them.

The technologies i am using is Apache/Tomcat, Java, Spring and Hibernate. Can someone help me, or guide me to some clear solution?

If you are looking for guide, then the documentation can help you a lot.

First thing, you need to understand the concept of Google Calendar API. You can read the basic concept on the overview page for further details. Moreover, if your aim is just more on the events, then you will need to make sure that you have visited this .

Here is a sample snippet all the way from the sample given in the documentation. This sample demonstrate creating an event and setting its metadata:

 // Refer to the Java quickstart on how to setup the environment: // https://developers.google.com/calendar/quickstart/java // Change the scope to CalendarScopes.CALENDAR and delete any stored // credentials. Event event = new Event() .setSummary("Google I/O 2015") .setLocation("800 Howard St., San Francisco, CA 94103") .setDescription("A chance to hear more about Google's developer products."); DateTime startDateTime = new DateTime("2015-05-28T09:00:00-07:00"); EventDateTime start = new EventDateTime() .setDateTime(startDateTime) .setTimeZone("America/Los_Angeles"); event.setStart(start); DateTime endDateTime = new DateTime("2015-05-28T17:00:00-07:00"); EventDateTime end = new EventDateTime() .setDateTime(endDateTime) .setTimeZone("America/Los_Angeles"); event.setEnd(end); String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"}; event.setRecurrence(Arrays.asList(recurrence)); EventAttendee[] attendees = new EventAttendee[] { new EventAttendee().setEmail("lpage@example.com"), new EventAttendee().setEmail("sbrin@example.com"), }; 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 = service.events().insert(calendarId, event).execute(); System.out.printf("Event created: %s\\n", event.getHtmlLink()); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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