0

I'm using Garethp/php-ews package to manage Exchange data.

I'm able to read Calendar that other user shared with me, but unless they gave me write access on their Calendar (Under web client, I can add event), I'm not able to add events trough php.

I think I have to use

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

If I'm right, how to get his $displayName ?

Thanks

kl3sk
  • 136
  • 1
  • 11

1 Answers1

0

I think I found a solution:

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

This script add event on a shared calendar.

kl3sk
  • 136
  • 1
  • 11