GoogleカレンダーをAPIで操作しているのですが、どうもcalendarIdの編集だけうまくいきません。
アドバイスを頂きたいです。
◆認証方法:OAuth 2.0
→認証はOK
◆新規登録は可能
◆calendarId以外(タイトル、時間、場所等)の項目は編集可能
【追記】
やっぱりID変更できないようなので、カレンダーオーナーを変更する方法を知りたいです。
削除して作り直す方が早いでしょうか?
JavaScript
1 function publishEvent(event) { 2 var record = kintone.app.record.get().record; 3 if (record) { 4 if (!gapi.auth2.getAuthInstance().isSignedIn.get()) { 5 gapi.auth2.getAuthInstance().signIn(); 6 alert('Google認証されていません。'); 7 return; 8 } 9 10 var params = { 11 'summary': record.title.value, 12 'start': { 13 'dateTime': record.event_date.value+"T"+record.start.value+":00.000+09:00", 14 }, 15 'end': { 16 'dateTime': record.event_date.value+"T"+record.end.value+":00.000+09:00", 17 }, 18 'location': record.pref.value+record.city.value+record.town.value+record.other.value, 19 'description': record.event_description.value 20 }; 21 var request; 22 if (record.event_id.value) { 23 request = gapi.client.calendar.events.update( 24 { 25 'calendarId': record.calendar_id.value, 26 'eventId': record.event_id.value, 27 'resource': params 28 } 29 ); 30 } else { 31 request = gapi.client.calendar.events.insert( 32 { 33 'calendarId': record.calendar_id.value, 34 'resource': params 35 } 36 ); 37 } 38 request.execute(function(resp) { 39 if (resp.error) { 40 alert('イベントの登録に失敗しました。'); 41 } else { 42 var body = { 43 'app': kintone.app.getId(), 44 'id': record.$id.value, 45 'record': { 46 'event_id': { 47 'value': resp.result.id 48 } 49 } 50 }; 51 return kintone.api(kintone.api.url('/k/v1/record', true), 'PUT', body).then(function(success) { 52 alert('カレンダーにイベントを登録しました。'); 53 location.reload(); 54 }).catch(function(error) { 55 alert('Google イベントIDの登録に失敗しました。'); 56 }); 57 } 58 }, function(error) { 59 alert('Google イベントIDの登録に失敗しました。'); 60 }); 61 } 62 }
回答3件
あなたの回答
tips
プレビュー