-
-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Labels
Description
The following code throws an exception:
// $tenantName, $privateKey, $clientId, $thumbprint are provided but left out here
$client = new GraphServiceClient(function () use ($tenantName, $privateKey, $clientId, $thumbprint) {
$resource = "https://graph.microsoft.com";
$provider = new AADTokenProvider($tenantName);
$credentials = new CertificateCredentials($resource, $clientId, $privateKey, $thumbprint, ['https://graph.microsoft.com/.default']);
return $provider->acquireTokenForClientCertificate($credentials);
});
$user = $client->getUsers()->getByUserPrincipalName('[email protected]');
/** @var \Office365\Outlook\Events\Event $event */
$event = $user->getEvents()->add();
$start = new DateTimeTimeZone();
$start->DateTime = '2025-10-01';
$start->TimeZone = 'Europe/Berlin';
$event->setStart($start);
$event->setIsAllDay(true);
$event->setBody(new ItemBody(0, 'Test'));
$addedChildQuery = $user->getEvents()->addChild($client); // here is the exception thrown
$addedChildQuery->executeQuery();But an exception is thrown:
ErrorException
Undefined property: Office365\GraphServiceClient::$parentCollection
at vendor/vgrem/php-spo/src/Runtime/ClientObjectCollection.php:138
134▕ */
135▕ public function addChild($clientObject)
136▕ {
137▕ $this->data[] = $clientObject;
➜ 138▕ if (is_null($clientObject->parentCollection))
139▕ $clientObject->parentCollection = $this;
140▕ return $this;
141▕ }
142▕
What am I doing wrong?
Does anybody know how to create an event in Office 365 with this library?