GoogleのカレンダーAPIを使用して特定のカレンダーの情報を取得しようとしています。このエラーが発生し続けるCannot read property 'signIn' of null
。私はここの例をオンラインで使用していますhttps://developers.google.com/google-apps/calendar/quickstart/js。GoogleカレンダーAPIが「プロパティを読み取れません」signIn 'of null'
これはなぜ起こっているのですか?誰かがカレンダーデータを取得するためのより簡単な方法を教えてくれますか?基本的には、カレンダーフィードのどの部屋が予約可能かを知りたいです。カレンダーAPIを使用してこれを行うことはできますか?
const CLIENT_ID = '418414126140-u5u3r2ampke8egh7d2tk50ferkl8ri26.apps.googleusercontent.com';
const SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"];
app.factory('getCalendar', ['$q', function($q){
return function checkAuth() {
var deferred = $q.defer();
function handleClientLoad() {
gapi.load('client:auth2', initClient);
}
handleClientLoad();
function initClient() {
gapi.client.init({
"client_id": CLIENT_ID,
"scope": SCOPES
}).then(function() {
gapi.auth2.getAuthInstance().signIn();
});
}
function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
console.log("You are authorized");
listUpcomingEvents();
} else {
console.log("You are not authorized");
}
}
function listUpcomingEvents() {
gapi.client.calendar.events.list({
'calendarId': 'primary',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 10,
'orderBy': 'startTime'
}).then(function(response) {
console.log(response);
deferred.resolve(response);
});
}
return deferred.promise;
} //return ends here
}]);
ありがとうございました。私はこのチュートリアルをオンラインで見つけました。このチュートリアルは、Googleのドキュメントと比較してはるかに使いやすいものです。 https://www.youtube.com/watch?v=0rZmp3Ew_kA カレンダーのどの部屋をチェックする方法はありますか? –