4D NetKit:GoogleとMicrosoft 365のカレンダーイベントを取得

Deeplからの自動翻訳

カレンダーやイベントの管理は、特にGoogle CalendarやMicrosoft 365のような一般的なサービスと統合する場合、多くのアプリケーションにとって非常に重要です。4D 20 R9からは、新しい4D NetKitコマンドを使って、これらのプラットフォームからカレンダーやイベントを簡単に取得し、アクセスすることができます。スケジュールの同期、カレンダーベースの機能の構築、イベントの詳細の取得など、これらのコマンドにより、GoogleやMicrosoft 365のサービスとのシームレスな統合が可能になります。

HDIカレンダー取得

以下の例では、GoogleカレンダーまたはMicrosoft 365アカウント内のすべてのカレンダーのリストと、リストの最初のカレンダーに関連付けられているすべてのイベントを取得します。

アカウント接続

いつものように、Google や Microsoft API を使う前にOAuth 2.0 接続オブジェクトを作成します:

Google APIの場合

var $oAuth2 : cs.NetKit.OAuth2Provider
var $google : cs.NetKit.Google
$oAuth2:=cs.NetKit.OAuth2Provider.new($googleCredentials)
$google:=cs.NetKit.Google.new($oAuth2)

Microsoft APIの場合

var $oAuth2: cs.NetKit.OAuth2Provider
var $office365 : cs.NetKit.Office365

$oAuth2:=cs.NetKit.OAuth2Provider.new($microsoftCredentials)
$office365:=cs.NetKit.Office365.new($oAuth2)

カレンダーリストの取得

特定のカレンダーのイベントを取得する前に、カレンダーIDを取得する必要があります。これを取得するには、.calendar.getCalendars ()関数を使用して、アカウントにリンクされているすべてのカレンダーをリストアップします。どちらのAPIもカレンダーを一覧表示するメソッドを提供していますが、パラメータや返されるオブジェクトはGoogleとMicrosoftで異なる場合があります。

Google API の場合

// Gets all the calendars 
var $calendars:=$google.calendar.getCalendars()
// For the rest of the example, we'll use the first calendar in the list
var $myCaldendar:=$calendars.calendars[0]

の場合

// Gets all the calendars 
var $calendars:=$office365.calendar.getCalendars()
// For the rest of the example, we'll use the first calendar in the list
var $myCaldendar:=$calendars.calendars[0]

イベント一覧を取得する

calendar.getEvents() 関数を使用して、特定のカレンダーにリンクされているイベントを取得することができます。どちらのAPIもイベントをリストアップするメソッドを提供していますが、パラメータや返されるオブジェクトはGoogleとMicrosoftで異なる可能性があります。

Google APIの場合

// Calculates the date range to be used
var $startDate:={date:Current date(); time:?00:00:00?}
var $endDate:={date:Current date()+7); time:?23:59:59?}
// Gets all the event of the selected calendars
var $events:=$google.calendar.getEvents({calendarId: $myCalendar.id; top: 100; singleEvents: True; startDateTime: $startDate; endDateTime: $endDate})

Microsoft APIの場合

// Calculates the date range to be used 
var $startDate:={date:Current date(); time:?00:00:00?}
var $endDate:={date:Current date()+7); time:?23:59:59?}
// Gets all the event of the selected calendars
var $events:=$office365.calendar.getEvents({calendarId: $myCalendar.id; top: 100; startDateTime: $startDate; endDateTime: $endDate})

blank

まとめ

4D 20 R9の新しい4D NetKitコマンドでカレンダーやイベントを管理するのは簡単です。Google CalendarでもMicrosoft 365でも、2つのプラットフォームの動作の違いを考慮しながら、カレンダーやイベントを素早く取得することができます。詳しくは、4D NetKitのドキュメントをご覧ください!

そして、これはほんの始まりに過ぎません。あなたのカレンダー統合をさらに強力にするために、もっと多くのコマンドや機能が近々登場します。

Fabrice Mainguené
- Product Owner -Fabrice Mainguenéは、2016年11月に4D Programチームに参加しました。プロダクトオーナーとして、彼はユーザーストーリーを書き、それを機能仕様に変換する役割を担っています。CNAMでコンピュータサイエンスの学士号を取得した後、FabriceはWindev開発者として小さなソフトウェア出版社に入社しました。その後、彼は産業および貿易分野のさまざまな企業で、Windev および Web 開発者として、また新機能の技術アドバイザーとして働きました。