2009-12-18 188 views

回答

1

我建議你可以指定在你的代碼像下面的代碼片段網址:

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情況下,將通過指定的URL檢索到的每一個日曆(初級,中級,導入的日曆)存儲。

+0

但是,如何獲取特定CalendarEntry實例的提要URL? pccCalendar.getEditLink()。getHref()不起作用。 – 2011-07-03 14:29:47

+0

pccCalendar.getEditLink()。getHref()將無法正常工作,除非您的日曆已被設置爲可公開訪問(我認爲) – user467257 2012-10-27 18:00:55

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); 
    } 
} 

詛咒谷歌爲他們diabolically混亂日曆的API。