gdata-api - Google 日历查询最多返回 25 个条目

标签 gdata-api google-calendar-api

我正在尝试从今天开始删除所有日历条目。我运行一个查询,然后在查询结果上调用 getEntries()。 getEntries() 始终返回 25 个条目(如果日历上的条目少于 25 个,则返回更少)。为什么没有返回所有条目?我期待大约 80 个条目。

作为测试,我尝试运行查询,删除返回的 25 个条目,再次运行查询,再次删除等。这有效,但必须有更好的方法。

下面是只运行一次查询的 Java 代码。

CalendarQuery myQuery = new CalendarQuery(feedUrl);

DateFormat dfGoogle = new SimpleDateFormat("yyyy-MM-dd'T00:00:00'");
Date dt = Calendar.getInstance().getTime();

myQuery.setMinimumStartTime(DateTime.parseDateTime(dfGoogle.format(dt)));
// Make the end time far into the future so we delete everything
myQuery.setMaximumStartTime(DateTime.parseDateTime("2099-12-31T23:59:59"));

// Execute the query and get the response
CalendarEventFeed resultFeed = service.query(myQuery, CalendarEventFeed.class);

// !!! This returns 25 (or less if there are fewer than 25 entries on the calendar) !!!
int test = resultFeed.getEntries().size();

// Delete all the entries returned by the query
for (int j = 0; j < resultFeed.getEntries().size(); j++) {
   CalendarEventEntry entry = resultFeed.getEntries().get(j);

   entry.delete();
}

PS:我看过 Data API Developer's GuideGoogle Data API Javadoc 。这些网站还可以,但不是很好。有谁知道其他 Google API 文档?

最佳答案

您可以使用 myQuery.setMaxResults() 增加结果数量。但是会有一个最大值,因此您可以通过改变 myQuery.setStartIndex() 进行多个查询(“分页”结果)。

http://code.google.com/apis/gdata/javadoc/com/google/gdata/client/Query.html#setMaxResults(int)
http://code.google.com/apis/gdata/javadoc/com/google/gdata/client/Query.html#setStartIndex(int)

关于gdata-api - Google 日历查询最多返回 25 个条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2646642/

相关文章:

php - 如何通过 Google 日历 php api 使用扩展属性

ios - 使用 GDataXML 获取 XML 响应值

python - YouTube-API上针对关键字/标签的无效字符错误(没有无效字符时)

c# - 以编程方式将 Google 日历共享设置设置为 "Make this calendar public"

python - 如何检索日历事件参加者

events - Google Calendar Watch 和 Events 协同工作

google-api - Google 日历事件描述中的 HTML 格式文本

php - 谷歌电子表格 API : memory exceeded

google-api - 通过 OAuth 2.0 和私钥又名服务帐户访问 Google Contacts Api

java - 谷歌日历 API 表示由于值无效( session 属性),出现 400 错误请求