32 lines
839 B
PHP
32 lines
839 B
PHP
<?php
|
|
/**
|
|
* Microsoft Graph Webhook Receiver
|
|
* Ontvangt subscription notifications voor /me/mailFolders('inbox')/messages en /me/events
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../config/database.php';
|
|
|
|
// Validatie bij aanmaken van Graph subscription
|
|
if (isset($_GET['validationToken'])) {
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
http_response_code(200);
|
|
echo $_GET['validationToken'];
|
|
exit;
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$raw = file_get_contents('php://input');
|
|
$data = json_decode($raw, true);
|
|
|
|
if ($data && isset($data['value'])) {
|
|
foreach ($data['value'] as $change) {
|
|
$resource = $change['resource'] ?? '';
|
|
$changeType = $change['changeType'] ?? '';
|
|
error_log("Microsoft Graph Webhook: {$changeType} op {$resource}");
|
|
}
|
|
}
|
|
|
|
echo json_encode(['received' => true]);
|
|
|