1

要访问 ExtendedProperties,我需要通知完整的投影。我见过的每个例子,他们都是通过 URL 来做的: https ://developers.google.com/google-apps/calendar/v2/reference#Event_feeds

https://www.google.com/calendar/feeds/userID/visibility/projection

但我没有那个网址。我按如下方式创建服务:

Calendar createService() throws GeneralSecurityException, IOException {
        GoogleCredential credential = new GoogleCredential.Builder()
                .setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY)
                .setServiceAccountId(EMAIL)
                .setServiceAccountScopes(CalendarScopes.CALENDAR)
                .setServiceAccountPrivateKeyFromP12File(new File(getClass().getClassLoader().getResource(FILE_NAME).getFile()))
                .build();

        Calendar service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                                       .setApplicationName("Rokko-Leggis")
                                       .build();
        return service;
    }

我试图保存和检索 ExtendedProperty 但失败了

如何保存自定义字段?

4

2 回答 2

1

成立!

    ExtendedProperties extended = new ExtendedProperties();
    Map<String, String> map = new HashMap<>();
    map.put("customField", "customValue");
    extended.setShared(map);
    event.setExtendedProperties(extended);
于 2013-04-09T17:14:11.540 回答
0

你可以用更少的两行来做到这一点:

this.calendarEvent.setExtendedProperties(new ExtendedProperties().setShared(extendedPropertiesMap));
于 2013-05-18T14:00:39.223 回答