Reputation: 9252
I have an object of CalendarEntry
I know that http://www.google.com/calendar/feeds/[email protected]/allcalendars/full is the feed url of all calendars
but how I can get this feed url from CalendarEntry instance?
Because I wanna post a new entry in a specified calendar and I need this url.
Thanks!
Upvotes: 3
Views: 2490
Reputation: 1742
If I understand your question correctly, you want to do this:
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);
}
}
Curse Google for their diabolically confusing calendar APIs.
Upvotes: 0
Reputation: 74134
I suggest you to specify that URL in your code like the following snippet:
CalendarService myService = new CalendarService("CalendarService");
myService.setUserCredentials("[email protected]", "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.
Upvotes: 1