我想我找到了解决方案:
$this->api = API::withUsernameAndPassword($server, $your_username, $your_password
$this->api->setPrimarySmtpEmailAddress('user_shared_calendar@test.com');
$folder = $this->api->getFolderByDistinguishedId('calendar');
$calendar = $this->api->getCalendar();
$calendar->setFolderId($folder->getFolderId());
$start = new \DateTime('now');
$start->setTimezone(new \DateTimeZone('Europe/Paris'));
$end = new \DateTime('now');
$end->add(new \DateInterval('PT1H'));
$calendar->createCalendarItems([
'Subject' => 'This is made by PHP',
'Body' => [
'BodyType' => API\Enumeration\BodyTypeType::HTML,
'_value' => 'This is <b>the</b> HTML body',
],
'Start' => $start->format('c'),
'End' => $end->format('c'),
]);
此脚本在共享日历上添加事件。