【问题标题】:google calendar java api谷歌日历 java api
【发布时间】:2009-12-18 14:34:27
【问题描述】:

我有一个 CalendarEntry 对象

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

但是如何从 CalendarEntry 实例中获取此提要 url?

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

谢谢!

【问题讨论】:

  • 你发现了吗?

标签: java google-api google-calendar-api


【解决方案1】:

我建议您在代码中指定该 URL,如下面的 sn-p:

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 检索到的每个日历(主日历、辅助日历、导入日历)。

【讨论】:

  • 但是如何获取特定 CalendarEntry 实例的提要 URL? pccCalendar.getEditLink().getHref() 不起作用。
  • pccCalendar.getEditLink().getHref() 将不起作用,除非您的日历已设置为可公开访问(我认为)
【解决方案2】:

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

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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 2017-08-30
    • 1970-01-01
    相关资源
    最近更新 更多