public static function freeBusyRequest($google_id, $token, $calendars, $start_date, $end_date)
 {
     $calendar_list = "";
     $i = 0;
     foreach ($calendars as $calendar) {
         $calendar_list .= '{"id":"' . $calendar . '"}';
         $i++;
         if ($i != count($calendars)) {
             $calendar_list .= ",";
         }
     }
     $response = ExternalRequest::POST("https://www.googleapis.com/calendar/v3/freeBusy", [], $google_id, $token, '
     {
      "timeMin": "' . $start_date . 'T00:00:00Z",
      "timeMax": "' . $end_date . 'T23:59:59Z",
      "items": [
        ' . $calendar_list . '
      ]
     }
     ');
     if (isset($response->calendars)) {
         return (array) $response->calendars;
     }
     return [];
 }
예제 #2
0
 public static function getCalendarsByUser($user_id)
 {
     $token = self::getTokenById($user_id);
     return ExternalRequest::GET('https://www.googleapis.com/calendar/v3/users/me/calendarList', $user_id, $token);
 }