将 Java 与 Google 日历连接

发布于 2024-09-18 20:46:44 字数 738 浏览 5 评论 0原文

我对 Java 比较陌生,所以我几乎不知道从哪里开始。我正在使用 Java 和谷歌日历编写一个日程安排应用程序。在我的谷歌帐户上,我有一堆日历,上面有人们的日程安排。我需要通过 java 访问这些日历,并将人员的空闲/忙碌信息插入到数组中,如下所示:

    //User 1
    int[][] swift_schedule = new int[5][6];
    //1 = busy, 0 = free

    //Monday
    swift_schedule[0][0] = 0;  //9-11
    swift_schedule[0][1] = 1;  //11-1
    swift_schedule[0][2] = 1;  //1-3
    swift_schedule[0][3] = 1;  //3-5
    swift_schedule[0][4] = 1;  //5-7
    swift_schedule[0][5] = 1;  //7-9
    //Tuesday
    swift_schedule[1][0] = 0; //9-11
    swift_schedule[1][1] = 0; //11-1
    swift_schedule[1][2] = 0; //1-3

    etc....

如果我使用 PHP,我将获得 XML feed 的 url,然后从中解析数据,但使用 JAVA 我不需要甚至不知道从哪里开始。有人能指出我正确的方向吗?教程、代码片段和其他提示将不胜感激!

干杯,
麦克风

I'm relatively new to Java, so I have little to no idea where to even start with this one. I'm writing a scheduling application using Java and google calendars. On my google account I have a bunch of calendars with people's schedules on them. I need to access these calendars through java and insert the person's free / busy information into arrays like so:

    //User 1
    int[][] swift_schedule = new int[5][6];
    //1 = busy, 0 = free

    //Monday
    swift_schedule[0][0] = 0;  //9-11
    swift_schedule[0][1] = 1;  //11-1
    swift_schedule[0][2] = 1;  //1-3
    swift_schedule[0][3] = 1;  //3-5
    swift_schedule[0][4] = 1;  //5-7
    swift_schedule[0][5] = 1;  //7-9
    //Tuesday
    swift_schedule[1][0] = 0; //9-11
    swift_schedule[1][1] = 0; //11-1
    swift_schedule[1][2] = 0; //1-3

    etc....

If I were using PHP, I would get a url for the XML feed and just parse the data out of it, but with JAVA I don't even know where to start. Can anyone point me in the right direction? Tutorials, code snippets, and other hints would be greatly appreciated!

cheers,
Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

べ繥欢鉨o。 2024-09-25 20:46:44

当有 Java API 时,您不必进行解析,只需使用它并查询您想要的日历事件即可。

使用 DateTimeCalendarQuery 您可以在以下位置查询事件特定的时间间隔(您的用例:获取给定日期的事件)。

CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(DateTime.parseDateTime("2006-03-16T00:00:00"));
myQuery.setMaximumStartTime(DateTime.parseDateTime("2006-03-24T23:59:59"));

Google 日历允许客户端
用于查看和更新​​的应用程序
Google 形式的日历事件
数据 API 源。你的客户
应用程序可以使用 Google
日历数据 API
创建新的
事件,编辑或删除现有的
事件,并查询事件
符合特定条件。

You don't have to do the parsing when there is a Java API for it, simply use it and query for the calendar events you want.

With DateTime and CalendarQuery you can query for events in a specific time interval (your use case: to get events in a give day).

CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(DateTime.parseDateTime("2006-03-16T00:00:00"));
myQuery.setMaximumStartTime(DateTime.parseDateTime("2006-03-24T23:59:59"));

Google Calendar allows client
applications to view and update
calendar events in the form of Google
Data API feeds. Your client
application can use the Google
Calendar Data API
to create new
events, edit or delete existing
events, and query for events that
match particular criteria.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文