Hi,
The following function iterates through your default calendar and
prints out all the essential properties of each event -
public void getAllEvent() throws Exception {
// Set up the URL and the object that will handle the
connection:
URL feedUrl = new
URL("http://www.google.com/calendar/feeds/default/
private/full");
// Send the request and receive the response:
CalendarEventFeed resultFeed = myService.getFeed(feedUrl,
CalendarEventFeed.class);
System.out.println("Totle results: " +
resultFeed.getTotalResults());
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEventEntry entry = resultFeed.getEntries().get(i);
String title = entry.getTitle().getPlainText();
System.out.println("Title: " + title);
String description = ((TextContent)
entry.getContent()).getContent().getPlainText();
System.out.println("Description: " + description);
List<Person> authors = entry.getAuthors();
List<When> whens = entry.getTimes();
List<EventWho> participants = entry.getParticipants();
Iterator iter = authors.iterator();
while(iter.hasNext()) {
Person author = (Person) iter.next();
String email = author.getEmail();
System.out.println("Author email" + email);
}
iter = participants.iterator();
while (iter.hasNext()) {
EventWho who = (EventWho) iter.next();
String email = who.getEmail();
System.out.println("Particpant email: " + email);
}
System.out.println(whens.size());
iter = whens.iterator();
while (iter.hasNext()) {
When when = (When) iter.next();
System.out.println("Start time: " +
when.getStartTime());
}
}
}
Hope it helps,
Austin
On Feb 7, 3:57 pm, Andre-John Mas <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using the Java GData API and I am trying to list the events for a
> given calendar. Below is the code that I have. Basically I loop
> through the available calendars and then try listing the events for
> the given calendar, but this does not work. What attribute can I get
> from the calendar entry to be able to use for listing the events
> specific to it?
>
> Andre
>
> CalendarFeed resultFeed = service.getFeed(getOwnCalendarsFeedUrl (),
> CalendarFeed.class);
> for ( CalendarEntry entry : resultFeed.getEntries() ) {
> listEventsForCalendar ( entry );
>
> }
>
> void listEventsForCalendar ( CalendarEntry calendar ) {
> CalendarEventFeed resultFeed = service.getFeed(calendar.getId(),
> CalendarEventFeed.class);
>
> for (int i = 0; i < resultFeed.getEntries().size(); i++) {
> CalendarEventEntry entry = resultFeed.getEntries().get(i);
> System.out.println("\t" + entry.getTitle().getPlainText());
> }
> System.out.println();
>
> }
>
> private URL getOwnCalendarsFeedUrl ( ) {
> String encodedUserName = null;
> try {
> encodedUserName = URLEncoder.encode(username,"UTF-8");
> return new URL( METAFEED_URL_BASE + encodedUserName +
> OWNCALENDARS_FEED_URL_SUFFIX );
> } catch (Exception e) {
> e.printStackTrace();
> }
> return null;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---