3

我有一个 CalendarEntry 对象

我知道http://www.google.com/calendar/feeds/example@gmail.com/allcalendars/full是所有日历的提要网址

但是我如何从 CalendarEntry 实例中获取这个提要 url?

因为我想在指定的日历中发布一个新条目,我需要这个 url。

谢谢!

4

2 回答 2

1

I suggest you to specify that URL in your code like 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 every calendars (primary, secondary,imported calendars) retrieved by the specified URL.

于 2010-04-09T13:49:56.777 回答
0

如果我正确理解你的问题,你想这样做:

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。

于 2012-10-27T17:38:35.647 回答