Google Calendar java api

I have a CalendarEntry object

I know that http://www.google.com/calendar/feeds/ example@gmail.com / allcalendars / full is the feed URL for all calendars

but how can I get this feed URL from a CalendarEntry instance?

Because I want to post a new entry in the specified calendar, and I need this url.

Thank!

+3
source share
2 answers

I suggest you specify this URL in your code as the following snippet:

CalendarService myService = new CalendarService("CalendarService");
myService.setUserCredentials("example@gmail.com", "yourPassword");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
System.out.println("Your calendars:");
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
  CalendarEntry entry = resultFeed.getEntries().get(i);
  System.out.println("\t" + entry.getTitle().getPlainText());
}

CalendarEntry instances will store all calendars (primary, secondary, imported calendars) received at the specified URL.

+1

, :

public static URL toCalendarFeedURL(CalendarEntry calendarEntry) {
    try {
        String cal = "https://www.google.com/calendar/feeds" + calendarEntry.getEditLink().getHref().substring(63) + "/private/full";
        return new URL(cal);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

Google API- .

0

Source: https://habr.com/ru/post/1726061/


All Articles