apex-google-api

インデックスに戻る link to github

概要

Google Calendar APIをApexから使用するためのライブラリです。


サンプル

Service Account認証

    SignServer sign = new SignServer('https://YOUR-APPNAME.herokuapp.com/sign');
    GoogleCalendarService service = new GoogleCalendarService(sign);
    JWT jwt = new JWT('YOUR-APPACOUNT@developer.gserviceaccount.com');
    service.authenticate(jwt);

カレンダー一覧取得

    GoogleCalendarService service;
    GoogleCalendar cal = null;
    List calList = service.listCalendarList().items;
    for (GoogleCalendar c : calList) {
        if (c.summary == 'My Calendar') {
            cal = c;
            break;
        }
    }

イベント作成

    GoogleCalendarService service;
    GoogleCalendar cal;
    GoogleCalendarEvent event = new GoogleCalendarEvent();
    event.summary = 'Test Event';
    event.setDateAndDuration(Datetime.newInstance(2013, 12, 12, 13, 0, 0), 60);//60 minutes
    event.location = 'Tokyo';
    event.description = 'Test Event';
    event.addAttendee('test1@flect.co.jp');
    event.addAttendee('test2@flect.co.jp');
    service.insertEvent(event);

ライセンス

MIT