我正在尝试访问包含国家法定假日的公共日历(来自Google日历):
calendarId: 'pt_br.brazilian#holiday@group.v.calendar.google.com'
Run Code Online (Sandbox Code Playgroud)
由于日历是公开的,我以为我只能使用API密钥访问它:
function OnLoadCallback() {
var config = {
client_id: '32j4lk32j5kj342l5h.googleuser.com', //fake client id
scope: 'https://www.googleapis.com/auth/calendar.readonly'
};
gapi.client.setApiKey('fId345AM20HXXXXXXXXXXXXXXXXgT3f9kyp2REfkaw2'); //fake api key
gapi.client.load('calendar', 'v3', function() {
var today = new Date(),
request;
request = gapi.client.calendar.calendarList.get({
calendarId: 'pt_br.brazilian#holiday@group.v.calendar.google.com',
timeMin: (new Date(today.getFullYear(), today.getMonth(), today.getDay(), 0, 0, 0, 0)).toISOString(),
timeMax: (new Date(today.getFullYear(), today.getMonth(), today.getDay(), 23, 59, 59, 999)).toISOString(),
fields: 'items(creator(displayName,email),end,endTimeUnspecified,start,summary)'
});
request.execute(function(response) {
window.alert('length of items: ' + response.items.length);
});
});
}
Run Code Online (Sandbox Code Playgroud)
但是,我一直收到以下响应,这是一个401(未授权)错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": …Run Code Online (Sandbox Code Playgroud) 我想使用JavaScript从Google Calendar API中提取一些国家/地区的假期列表.
可能吗?我怎样才能做到这一点?
如何使用javascript或jquery 使用Google日历获取所选国家/地区的假日列表?
这是可能的?有什么建议吗?
我正在使用Google Calendar API V3并使用javascript.我在android中找到了一些例子,但我对android一无所知.