简体   繁体   English

无法将Google日历事件显示为全日历

[英]Can't display google calendar events to fullcalendar

This has been asked a lot of times but I can't find any answer that works for me. 这已经被问了很多遍了,但是我找不到适合我的答案。 I followed all the steps on full calendar's site but that doesn't work either. 我按照完整日历网站上的所有步骤进行操作,但这也不起作用。 I can see the calendar but no events. 我可以看到日历,但没有事件。 I've written the code into a separate javascript file called 'addCalendarEvents.js' 我已将代码写入名为“ addCalendarEvents.js”的单独的javascript文件中
Here is the code and the error I get. 这是代码和我得到的错误。
HTML: HTML:

 <link href="https://fonts.googleapis.com/css?family=Open+Sans:200,300,400" rel="stylesheet">
 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
 <link rel='stylesheet' href='fullcalendar/fullcalendar.css' />

<script src='jquery-3.1.1.min.js'></script>

<script src='fullcalendar/lib/jquery.min.js'></script>
<script src='fullcalendar/lib/moment.min.js'></script>
<script src='fullcalendar/fullcalendar.js'></script>
<script type='text/javascript' src='fullcalendar/gcal.js'></script>
<script src='addCalendarEvent.js' type='text/javascript'></script>

Javascript: 使用Javascript:

    $(document).ready(function() {
    console.log('..');
    $('#calendar').fullCalendar({
         header: {
                  left: 'prev,next today',
                  center: 'title',
                  right: 'month,agendaWeek,agendaDay'
                },
        googleCalendarApiKey: 'AIzaSyAV4rl5GymKTDcHd44U7k48GgGQoeKzsuI',
        eventSources: [{ 
                   googleCalendarApiKey: 'AIzaSyAV4rl5GymKTDcHd44U7k48GgGQoeKzsuI',
                   googleCalendarId: 'vesit.network17@gmail.com',
                   className: 'fc-event-email'
                   }]

        });
    });

Screenshot: errors with the calendar 屏幕截图: 日历错误

I'm at a total loss. 我完全不知所措。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。

The value for the googleCalendarId ...@gmail.com specified by you does not look like a valid calendar ID. 您指定的googleCalendarId ...@gmail.com的值看起来像无效的日历ID。 That's supposedly the email address that belongs to a google account where the desired calendar exists. 这可能是属于所需日历存在的Google帐户的电子邮件地址。 Did you have something particular in mind doing so? 你有什么特别的想法吗? - As one can have multiple calendars (eg on different topics) in one's google account, a specific ID of the calendar is naturally needed! -由于一个人的Google帐户可以有多个日历(例如,关于不同主题的日历),因此自然需要日历的特定ID! Any information on a google account becomes irrelevant with the concept of publically made available calendars, right?! Google帐户上的任何信息都与公开可用日历的概念无关,对吗? Those calendars made publically accessible are like balloons which are attached to a gmail account. 那些可公开访问的日历就像是附加到gmail帐户的气球一样。 They fly high in the air, accessible for everyone. 他们高高地飞翔,每个人都可以进入。 Such balloons are labeled with googleCalendarIds. 这些气球标有googleCalendarIds。

More precisely, @group.calendar.google.com should be the last part of the most widely used calendar IDs. 更确切地说, @group.calendar.google.com应该是使用最广泛的日历ID的最后一部分。 You can find the calendar ID in the Google Calendar Interface under 'My calendars' on the left. 您可以在Google日历界面的左侧“我的日历”下找到日历ID。 Then under 'Calendar settings'. 然后在“日历设置”下。 One should make sure that the calendar has been made public in order that fullCalendar.js can request the calendar data. 应该确保日历已公开,以便fullCalendar.js可以请求日历数据。

The fullCalendar documentation chapter on Google Calendar gives detailed information on the googleCalendarId and where to find it at Google Calendar Interface. Google日历上的完整日历文档章节提供了有关googleCalendarId的详细信息以及在Google日历界面中可以找到它的位置。 As well, the source code from the gcal.html example in the demos folder from the downloaded fullCalendar zip file gives a good basic example. 同样,下载的fullCalendar zip文件中demos文件夹中gcal.html示例的源代码提供了一个很好的基本示例。

Sidenote: You could, in case you only need to refer to one calendar, simplify your code by using 旁注:如果您只需要引用一个日历,则可以使用

googleCalendarApiKey: '......yourAPI-key......',
events: {
            googleCalendarId: '......@group.calendar.google.com'
        }

Is there a particular reason why you used eventSources, including the statement className 'fc-event-email'? 为什么使用eventSources(包括语句className'fc-event-email')有特定的原因吗? That seems to make things complicated. 这似乎使事情变得复杂。 The approach is not known to me, but it is already more code than usual for the task you described in your question. 我不知道这种方法,但是对于您在问题中描述的任务,它已经比平时更多的代码。 For a normal Google Calendar API integration into fullCalendar the above mentioned changes are one possible solution to your problem. 对于将Google Calendar API正常集成到fullCalendar中,上述更改是解决您的问题的一种可能。 Hopefully, happy calendar ballooning, Sir! 希望主席先生,日历愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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