0

我正在使用 Garethp/php-ews包来管理 Exchange 数据。

我可以阅读其他用户与我共享的日历,但除非他们授予我在他们的日历上的写入权限(在 Web 客户端下,我可以添加事件),否则我无法通过 php 添加事件。

我想我必须使用

$calendar = $api->getCalendar();
$userCalendar = $calendar->pickCalendar($displayName);

如果我是对的,如何得到他的$displayName

谢谢

4

1 回答 1

0

我想我找到了解决方案:

$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'),
]);

此脚本在共享日历上添加事件。

于 2020-11-16T19:04:45.417 回答