Need good example: Google Calendar API in Javascript

前端 未结 1 1147
醉话见心
醉话见心 2020-11-28 06:49

What I\'m trying to do: Add events to a google calendar from my site using javascript.

What I can\'t do: Find a good tutorial/walk through/example for the google cal

相关标签:
1条回答
  • 2020-11-28 07:24

    Google provides a great JS client library that works with all of Google's discovery-based APIs (such as Calendar API v3). I've written a blog post that covers the basics of setting up the JS client and authorizing a user.

    Once you have the basic client enabled in your application, you'll need to get familiar with the specifics of Calendar v3 to write your application. I suggest two things:

    • The APIs Explorer will show you which calls are available in the API.
    • The Chrome developer tools' Javascript console will automatically suggest method names when you are manipulating gapi.client. For example, begin typing gapi.client.calendar.events. and you should see a set of possible completions (you'll need the insert method).

    Here's an example of what inserting an event into JS would look like:

    var resource = {
      "summary": "Appointment",
      "location": "Somewhere",
      "start": {
        "dateTime": "2011-12-16T10:00:00.000-07:00"
      },
      "end": {
        "dateTime": "2011-12-16T10:25:00.000-07:00"
      }
    };
    var request = gapi.client.calendar.events.insert({
      'calendarId': 'primary',
      'resource': resource
    });
    request.execute(function(resp) {
      console.log(resp);
    });
    

    Hopefully this is enough to get you started.

    0 讨论(0)
提交回复
热议问题