简体   繁体   中英

How do I use the Google Calendar API with Java?

I am using IntelliJ IDEA.

I downloaded the JARs from: https://developers.google.com/api-client-library/java/apis/#Calendar_API

I copied the libs folder inside the downloaded zip into my project folder and right clicked the JARs and selected "Add as Library."

However, the IDE doesn't recognize these imports:

import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.*;

How would I integrate the Google Calendar API into my IntelliJ IDEA Java project?

I am doing this so I can write a Java application that will clone my calendar but move all my events into two days in advance.

This is a follow up to https://superuser.com/questions/654799/cloning-a-google-calendar

Also, I'm not quite sure how this Google Calendar API works. Would I run the Java application locally and it creates the clone on the server or would I have to upload my Java source files to the server so that it runs it remotely sort of like a Google Calendar plugin?

  1. You need to read through the README / index file that tells you what jars are required for the various environments.

  2. Alternatively if your project is based on gradle / maven - then define the dependency and then generate the Idea project files from the build tool. This way all the required jars will be setup automatically.

For your other question, you can run the application locally and do the whole cloning bit. General steps would be:

  1. Login
  2. Fetch the available calendars
  3. Select a calendar to clone
  4. Create a new calendar & recreate all the events that you wish to copy over from the base calendar.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM