Fullcalendar 完整日历+;私有谷歌日历

Fullcalendar 完整日历+;私有谷歌日历,fullcalendar,google-calendar-api,Fullcalendar,Google Calendar Api,我正在为一个web应用程序项目使用完整日历,我将它与我客户端的google日历同步,但目前只有公共日历 有没有办法与私人日历同步 注意:我们使用0auth来识别Google帐户并与之同步 谢谢我想如果使用正确的授权,它将与私人日历一起工作 对Google日历API的所有请求必须由经过身份验证的用户授权 以下是创建人的示例: var clientId=''; var-apiKey=''; var作用域https://www.googleapis.com/auth/calendar'; 函数han

我正在为一个web应用程序项目使用完整日历,我将它与我客户端的google日历同步,但目前只有公共日历

有没有办法与私人日历同步

注意:我们使用0auth来识别Google帐户并与之同步


谢谢

我想如果使用正确的授权,它将与私人日历一起工作

对Google日历API的所有请求必须由经过身份验证的用户授权

以下是创建人的示例:


var clientId='';
var-apiKey='';
var作用域https://www.googleapis.com/auth/calendar';
函数handleClientLoad(){
gapi.client.setApiKey(apiKey);
setTimeout(checkAuth,1);
}
函数checkAuth(){
auth.authorize({client_id:clientId,scope:scopes,immediate:true},handleAuthResult);
}
函数handleAuthResult(authResult){
var authorizeButton=document.getElementById('authorized-button');
if(authResult&!authResult.error){
authorizeButton.style.visibility='hidden';
makeApiCall();
}否则{
authorizeButton.style.visibility='';
authorizeButton.onclick=handleAuthClick;
GeneratePublicCalendar();
}
}
函数handleAuthClick(事件){
auth.authorize({client_id:clientId,scope:scopes,immediate:false},handleAuthResult);
返回false;
}
//加载API并进行API调用。在屏幕上显示结果。
函数makeApiCall(){
//步骤4:加载Google+API
load('calendar','v3')。然后(function(){
//步骤5:组装API请求
var请求=gapi.client.calendar.events.list({
“日历ID”:”
});
//步骤6:执行API请求
请求。然后(功能(resp){
var eventsList=[];
var-successArgs;
var成功;
如果(响应结果错误){
reportError('Google日历API:'+data.error.message,data.error.errors);
}
其他如果(分别结果项){
$。每个(分别为结果项、功能(i、条目){
var url=entry.htmlink;
//使每个事件的URL在正确的时区显示时间
//如果(时区搜索){
//url=injectQsComponent(url,'ctz='+timezoneArg);
//}
事件列表推送({
id:entry.id,
标题:entry.summary,
开始:entry.start.dateTime | | entry.start.date,//try timed。将返回到整天
结束:entry.end.dateTime | | entry.end.date,//相同
url:url,
地点:entry.location,
description:entry.description
});
});
//调用成功处理程序并允许它返回新的事件数组
successArgs=[eventsList].concat(Array.prototype.slice.call(arguments,1));//转发其他jq参数
successRes=$.fullCalendar.applyAll(true、this、successArgs);
如果($.isArray(successRes)){
返回成功者;
}
}
如果(eventsList.length>0)
{
//在此处创建日历,但事件选项为:
//fullcalendar.events:eventsList(仍在寻找一种方法,可以删除当前事件并填充这些新闻事件,而无需重新创建日历)。
}
返回事件列表;
},功能(原因){
console.log('错误:'+原因.结果.错误.消息);
});
});
}
函数GeneratePublicCalendar(){
//当用户未登录时,您需要一个带有googleApi的普通fullcalendar
$(“#日历”).fullCalendar({
GoogleKey:“”,
...
});  
}

在企业应用程序中,您可能希望以编程方式访问用户数据,而无需用户的任何手动授权。在Google Apps域中,域管理员可以向第三方应用程序授予对其用户数据的全域访问权限,这称为全域授权。要以这种方式授权,请执行以下操作:主要管理员可以在OAuth 2.0中使用服务帐户

有关更多详细信息,请参阅


希望这能有所帮助!

我在后端尝试使用php,使用google php客户端库获取事件,然后将其放入fullcalendar。这样,它就可以工作了

<script type="text/javascript">

            var clientId = '<your-client-id>';
            var apiKey = '<your-api-key>';
            var scopes = 'https://www.googleapis.com/auth/calendar';

            function handleClientLoad() {
                gapi.client.setApiKey(apiKey);
                window.setTimeout(checkAuth,1);
            }

            function checkAuth() {
                gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
            }

            function handleAuthResult(authResult) {
                var authorizeButton = document.getElementById('authorize-button');
                
                if (authResult && !authResult.error) {
                    authorizeButton.style.visibility = 'hidden';          
                    makeApiCall();
                } else {
                    authorizeButton.style.visibility = '';
                    authorizeButton.onclick = handleAuthClick;
                    GeneratePublicCalendar();
                }
            }

            function handleAuthClick(event) {            
                gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
                return false;
            }
            
            
            // Load the API and make an API call.  Display the results on the screen.
            function makeApiCall() {

                // Step 4: Load the Google+ API
                gapi.client.load('calendar', 'v3').then(function() {
                  // Step 5: Assemble the API request
                      var request = gapi.client.calendar.events.list({
                            'calendarId': '<your-calendar-id(The @gmail.com>'
                        });
                  
                        // Step 6: Execute the API request
                        request.then(function(resp) {

                            var eventsList = [];
                            var successArgs;
                            var successRes;

                            if (resp.result.error) {
                                reportError('Google Calendar API: ' + data.error.message, data.error.errors);
                            }
                            else if (resp.result.items) {
                                $.each(resp.result.items, function(i, entry) {
                                    var url = entry.htmlLink;

                                    // make the URLs for each event show times in the correct timezone
                                    //if (timezoneArg) {
                                    //    url = injectQsComponent(url, 'ctz=' + timezoneArg);
                                    //}

                                    eventsList.push({
                                        id: entry.id,
                                        title: entry.summary,
                                        start: entry.start.dateTime || entry.start.date, // try timed. will fall back to all-day
                                        end: entry.end.dateTime || entry.end.date, // same
                                        url: url,
                                        location: entry.location,
                                        description: entry.description
                                    });
                                });

                                // call the success handler(s) and allow it to return a new events array
                                successArgs = [ eventsList ].concat(Array.prototype.slice.call(arguments, 1)); // forward other jq args
                                successRes = $.fullCalendar.applyAll(true, this, successArgs);
                                if ($.isArray(successRes)) {
                                    return successRes;
                                }
                            }

                            if(eventsList.length > 0)
                            {
                              // Here create your calendar but the events options is :
                              //fullcalendar.events: eventsList (Still looking for a methode that remove current event and fill with those news event without recreating the calendar.
                              
                            }
                          return eventsList;
                            
                      }, function(reason) {
                        console.log('Error: ' + reason.result.error.message);
                      });
                });
            }

function GeneratePublicCalendar(){  
  // You need a normal fullcalendar with googleApi when user isn't logged
  
    $('#calendar').fullCalendar({
                    googleCalendarApiKey: '<your-key>',      
      ...
    });  
}
</script>
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>