Update: 2026-07-05 00:06:55

This commit is contained in:
Hamza-Ayed
2026-07-05 00:06:55 +03:00
parent a0e9bd3cbb
commit 35c0a6680c
10 changed files with 300 additions and 0 deletions
+28
View File
@@ -7,6 +7,7 @@
require_once __DIR__ . '/../core/bootstrap.php';
require_once __DIR__ . '/../functions.php';
require_once __DIR__ . '/../core/Services/SiroGeminiService.php';
require_once __DIR__ . '/../core/Services/FcmService.php';
header('Content-Type: application/json');
@@ -87,11 +88,38 @@ try {
// Save to database
$stmt = $con->prepare("INSERT INTO marketing_reports (platform, report_html) VALUES (?, ?)");
$stmt->execute([$platform, $reportHtml]);
$reportId = $con->lastInsertId();
// Send FCM notification to admins
$fcm = new FcmService();
$fcm->send(
token: '/topics/admin_alerts',
title: 'New Social Media Intelligence Report 📊',
body: "A new autonomous analysis report for {$platform} has been generated.",
data: [
'type' => 'marketing_report',
'report_id' => $reportId,
'platform' => $platform
],
category: 'marketing_report'
);
}
echo json_encode(['status' => 'success', 'message' => 'Posts evaluated and report saved']);
break;
case 'get_reports':
$stmt = $con->prepare("
SELECT id, platform, report_html, is_weekly, created_at
FROM marketing_reports
ORDER BY created_at DESC
LIMIT 50
");
$stmt->execute();
$reports = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['status' => 'success', 'data' => $reports]);
break;
default:
echo json_encode(['status' => 'error', 'message' => 'Invalid action']);
}