I'm trying to fire an event when I create a calendar item (appointment) in exchange, using PHP-EWS. Currently, I am able to fire an event when an email is sent:
$subscribe_request = new \EWSType_SubscribeType();
$pushSubscription = new \EWSType_PushSubscriptionRequestType();
$pushSubscription->StatusFrequency = 1;
$pushSubscription->URL = 'http://someserver/log.php';
$folderIDs = new \EWSType_NonEmptyArrayOfBaseFolderIdsType();
$eventTypes = new \EWSType_NonEmptyArrayOfNotificationEventTypesType();
$folderIDs->DistinguishedFolderId = new \EWSType_DistinguishedFolderIdType();
$folderIDs->DistinguishedFolderId->Id = \EWSType_DistinguishedFolderIdNameType::INBOX;
$eventTypes->EventType = "NewMailEvent";
$pushSubscription->FolderIds = $folderIDs;
$pushSubscription->EventTypes = $eventTypes;
$subscribe_request->PushSubscriptionRequest = $pushSubscription;
return $this->ews->Subscribe($subscribe_request);
log.php
class ewsService {
public function SendNotification($arg) {
file_put_contents("C:\\exchangelogs\\log_".time().".txt", print_r($arg,1));
$result = new EWSType_SendNotificationResultType();
$result->SubscriptionStatus = 'OK';
//$result->SubscriptionStatus = 'Unsubscribe';
return $result;
}
}
$opts = array();
$server = new SoapServer(
'NotificationService.wsdl',
array('uri' => 'http://someserver/log.php'));
$server->setObject($service = new ewsService());
$server->handle();
Every minute a 'Keep alive message' is sent and the SendNotification
function is called. The same thing happens when a mail is sent (using outlook or whatever).
This all works fine.
However, now I want to do the same when a calendar item is created, such as an appointment. I tried changing the DistinguishedFolderIdNameType
to CALENDAR
and the EventType
to CreatedEvent
, but I receive no message when an appointment is created.
Any help is greatly appreciated.