- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何将 CalendarEvent 插入到由其 Id 给定的特定日历?
在我的应用程序中,我正在扫描所有日历并将它们添加到 ArrayList,如下所示:
for (CalendarListEntry calendarEntry : this.calendars.getItems()) {
this.calendarIDs.add(calendarEntry.getId());
}
我找到的唯一代码片段是:
Event createdEvent = service.events().insert("primary", event).execute();
我尝试使用 feed url 而不是“private”,比如
http://www.google.com/calendar/feeds/<id_here>%40group.calendar.google.com/private/full
但后来我得到了一个
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Not Found",
"reason" : "notFound"
}],
"message" : "Not Found"
}
最佳答案
试试这些代码片段:
片段 1:
public void authenticate(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
List <String> scopes = new LinkedList<String>();
scopes.add(scope);
AuthorizationCodeRequestUrl authorize = new GoogleAuthorizationCodeRequestUrl(client_id, redirect_uri, scopes);
authorize.setRedirectUri(redirect_uri);
String authorize_url = authorize.build();
log.info(authorize_url);
response.sendRedirect(authorize_url);
}
片段一负责 OAuth 并将程序重定向到重定向 uri。变量 scope、client_id、cliend_secret 和 scope 的值来自 Google api 控制台。
片段 2:
public void importCalendarList(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String code = request.getParameter("code");
HttpTransport transport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleTokenResponse res = new GoogleAuthorizationCodeTokenRequest(transport, jsonFactory, client_id, client_secret, code, redirect_uri).execute();
]String accessToken = res.getAccessToken();
Calendar.Builder builder = new Calendar.Builder(transport, jsonFactory, null);
builder.setCalendarRequestInitializer(new CalendarRequestInitializer(accessToken));
Calendar calendarService = builder.build();
Calendar.CalendarList.List list = calendarService.calendarList().list();
list.setOauthToken(accessToken);
List <CalendarListEntry>list1=list.execute().getItems();
String id = list1.get(0).getId();
p.write(id);
for(CalendarListEntry temp:list1) {
p.println(temp.getSummary());
temp.getId();
}
Event e = new Event();
e.setSummary("Test event");
e.setLocation("Adaptavant");
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
e.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
e.setEnd(new EventDateTime().setDateTime(end));
Event insertedEvent = calendarService.events().insert(id, e).setOauthToken(accessToken).execute();
p.println(insertedEvent.getId());
代码段二获取日历列表并获取其中一个的 ID,并在该日历中创建一个事件。如果您想将事件添加到主日历,主日历的 ID 是用于登录的 gmail ID。
可在此处找到更多文档:
https://google-api-client-libraries.appspot.com/documentation/calendar/v3/java/latest/index.html
关于java - 将 CalendarEvent 插入到 "primary"以外的其他日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13986099/
我已经坚持了好几天了……很抱歉遇到这样的问题,但是我只是F#本身的初学者。由于关于类型提供程序的讨论很多,所以我决定建立一个类型提供程序并撰写一篇有关它的论文。当我开始时,我不知道什么是类型提供程序。
我正在开发LAN项目唤醒功能,但是我想控制局域网中计算机是否打开。但是我不想使用ICMP或WMI(我的网络上有DC)。那么,对于此问题,是否还有其他选择,例如“套接字连接”,请检查特定端口是否正在使用
我们有一个旧的VB6应用程序,该应用程序使用Crystal Reports XI生成打印报告。我们已经通过经验发现,如果Crystal Reports打印引擎选择了错误版本的 usp10.dll (W
我正在尝试获取有效的 Android 权限列表。我知道 http://developer.android.com/reference/android/Manifest.permission.html
嗨,我是 nginx 的新手,我试图在我的服务器(运行 Ubuntu 4)上设置它,它已经运行了 apache。 所以在我 apt-get install 它之后,我尝试启动 nginx。然后我收到这
如何在VB 6中检查对象的类型-除了'TypeName'之外,是否还有其他方法,因为无法通过'TypeName'进行检查,我希望使用类似QuichWatch窗口的方法。 最佳答案 对于对象变量,请使用
我的 JSP 应用程序中有一个错误。发布后我的 session 被清除: YAHOO.util.Connect.asyncRequest('POST', Url, callback, post
我是一名优秀的程序员,十分优秀!