如何通过 ID 获取单个 GoogleCalendar CalendarEventEntry?
我正在尝试检索单个 CalendarEventEntry 来自 Google 日历的事件 ID,但我找不到执行此操作的方法。该 API 似乎没有为此提供方法,但它建议使用 查询。这样做的缺点是 ID 不是考虑的参数之一。
我认为实现此目的的一种可能方法是获取 CalendarEventFeed 与我们的日历关联,然后迭代生成的事件列表,如下所示:
CalendarService service = new CalendarService(applicationName);
service.setUserCredentials(userName,password);
CalendarEventFeed myFeed = service.getFeed(feedUrl, CalendarEventFeed.class);
List <CalendarEventEntry> entries = myFeed.getEntries();
for (CalendarEventEntry e : entries){
if (e.getId().equals(id)){
return e;
}
}
您知道有任何更简单、更直接的解决方案来实现此目的吗?
提前致谢!
I'm trying to retrieve a single CalendarEventEntry from a Google Calendar by the event ID but I can't find the way to do it. It seems that the API doesn't provide a method for this, though it suggests to make a query to the feed calendar using Query. The drawback of this is that the ID is not one of the parameters considered.
I think that a possible way to achieve this would be to get the CalendarEventFeed associated with our calendar and then iterate over the resulting list of events as follows:
CalendarService service = new CalendarService(applicationName);
service.setUserCredentials(userName,password);
CalendarEventFeed myFeed = service.getFeed(feedUrl, CalendarEventFeed.class);
List <CalendarEventEntry> entries = myFeed.getEntries();
for (CalendarEventEntry e : entries){
if (e.getId().equals(id)){
return e;
}
}
Do you know any easier and more straight solution to achieve this ??
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过调用
calendarEventEntry.getEditLink().getHref()
获取事件的URL。它实际上是日历的 url 加上事件 id。请参阅数据 API 开发人员指南代码示例。
You can get the URL of the event by calling
calendarEventEntry.getEditLink().getHref()
. It is actually the url of the calendar plus the event id.Take a look at the Data API Developer Guide for code samples.
这家伙的问题有根据,没有代码来回答这个问题。下面找到我用来回答这个问题的代码。我稍微修改了您的代码
注意: feedUrl - 这是您在日历设置下找到的日历 URL
事件 ID 的格式为 http://www.google.com/calendar/feeds/email%40gmail.com/events/EventIDLastPart
例如
http://www.google.com/calendar/feeds/email%40gmail.com/events/ghytrueueyryrgfuur
希望对
恩戈尼丹有帮助
The guys question has basis, there was no code to answer this question. Find below the code i used to answer this question. I modified your code slightly
NOTE: feedUrl - That is the Calendar URL you find under the calendar settings
An event id has the format http://www.google.com/calendar/feeds/email%40gmail.com/events/EventIDLastPart
e.g.
http://www.google.com/calendar/feeds/email%40gmail.com/events/ghytrueueyryrgfuur
Hope it helps
Ngonidan