Tag: google calendar api

在Android中使用google-java-api-client获取Google日历活动的开始和结束时间

如何使用google-api-java-client解析用户Google日历中事件的开始和结束时间? 从谷歌代码安装这个示例Android项目后,我可以进入我的谷歌日历并解析一些信息(如所有日历,事件名称,发布时间和摘要),但我不能为我的生活获取活动的开始和结束时间。 我对代码的理解就是这样。 在主活动类(CalendarAndroidSample.java)中,这是获取每个日历标题的方法: void executeRefreshCalendars() { String[] calendarNames; List calendars = this.calendars; calendars.clear(); try { CalendarUrl url = CalendarUrl.forAllCalendarsFeed(); // page through results while (true) { CalendarFeed feed = client.executeGetCalendarFeed(url); if (feed.calendars != null) { calendars.addAll(feed.calendars); } String nextLink = feed.getNextLink(); if (nextLink == null) { break; } } int numCalendars = calendars.size(); calendarNames […]

使用java离线访问谷歌日历

我们有代码将我们的应用程序日历与登录用户的Google日历同步。 该代码使用的是AuthSub和CalendarService类,但它不提供使用访问令牌和刷新令牌的谷歌日历的离线访问,因为我想使用日历类来使用OAuth v3。 我面临的问题是将我的旧代码合并到没有getFeed()函数的新v3 Calendar类。 这是我的应用程序中的一些代码 if(StringUtil.isValid(request.getQueryString())) { onetimeUseToken = AuthSubUtil.getTokenFromReply(request.getQueryString()); } if(StringUtil.isValid(onetimeUseToken)) { String sessionToken = AuthSubUtil.exchangeForSessionToken(onetimeUseToken,null); CalendarService calendarService = new CalendarService(“myapp”); calendarService.setAuthSubToken(sessionToken, null); session.setAttribute(“calendarServicesession”,calendarService); userIDforCalendar = (String) session.getAttribute(“calendar_user_no”); } CalendarFeed myResultsFeed1 =service.getFeed(new URL(“https://www.google.com/calendar/feeds/default/allcalendars/full”),CalendarFeed.class); for (int i = 0; i < myResultsFeed1.getEntries().size(); i++) { CalendarEntry entry = myResultsFeed1.getEntries().get(i); ….. } 请提供一些使用CalendarService进行离线访问的方法,这样我就不必更改代码了。 希望能快速回复。 谢谢 – […]

授权谷歌日历api适用于个人帐户,但不适用于谷歌域帐户

我需要创建一个Java应用程序,在Google Domain中的员工中存储日历事件。 我根据http://code.google.com/p/google-api-java-client/wiki/APIs#Calendar_API上的示例创建了应用程序 现在我想让它在谷歌域名的帐户上工作,然后我突然陷入困境。 我用一个新文件更改了client_secrets.json文件。 在code.google.com/apis/console上为已安装的应用生成,现在我收到了无效的客户端错误: ex =(com.google.api.client.auth.oauth2.TokenResponseException)com.google.api.client.auth.oauth2.TokenResponseException:400 Bad Request {“error”:“unauthorized_client”} 我需要为此做其他步骤吗? 此外,它需要在域内默认使用所有帐户而不是单个帐户。 也许其他控制台? 我希望不是其他图书馆。