代码之家  ›  专栏  ›  技术社区  ›  Tommaso Taruffi

谷歌日历java api

  •  3
  • Tommaso Taruffi  · 技术社区  · 15 年前

    我知道 http://www.google.com/calendar/feeds/example@gmail.com/allcalendars/full 是所有日历的源url

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

    谢谢!

    2 回复  |  直到 14 年前
        1
  •  1
  •   systempuntoout    15 年前

    我建议您在代码中指定该URL,如下片段所示:

    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实例将存储由指定URL检索的每个日历(主日历、辅助日历、导入的日历)。

        2
  •  0
  •   user467257    12 年前

    如果我正确理解您的问题,您可以这样做:

    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。