Accessing Google Calendar API without authorization via JavaScript

后端 未结 1 1545
遇见更好的自我
遇见更好的自我 2020-12-24 14:36

I\'m trying to access a public calendar (from Google Calendar) that contains national holidays:

calendarId: \'pt_br.brazilian#holiday@group.v.calendar.google         


        
相关标签:
1条回答
  • 2020-12-24 15:00

    I was able to do the same thing using jQuery.

    var mykey = 'your_api_key'; // typically like Gtg-rtZdsreUr_fLfhgPfgff
    var calendarid = 'you_calendar_id'; // will look somewhat like 3ruy234vodf6hf4sdf5sd84f@group.calendar.google.com
    
    $.ajax({
        type: 'GET',
        url: encodeURI('https://www.googleapis.com/calendar/v3/calendars/' + calendarid+ '/events?key=' + mykey),
        dataType: 'json',
        success: function (response) {
            //do whatever you want with each
        },
        error: function (response) {
            //tell that an error has occurred
        }
    });
    

    However you need to be sure you have done the following:-


    1) Register a project at https://code.google.com/apis/console
    2) Generate a Simple API Access key
    3) Ensure Calendar API is activated under services.

    Read more at https://developers.google.com/google-apps/calendar/firstapp

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