Files
whatsapp/api/get_notifications.php
T
2026-01-21 02:49:42 -05:00

20 lines
617 B
PHP

<?php
require_once '../config/config.php';
requireAuthentication();
header('Content-Type: application/json; charset=utf-8');
try {
$db = Database::getInstance();
$limit = isset($_GET['limit']) ? intval($_GET['limit']) : 20;
$rows = $db->fetchAll(
"SELECT id, user_id, type, message, data, is_read, created_at FROM notifications WHERE is_read = 0 ORDER BY created_at DESC LIMIT ?",
[$limit]
);
echo json_encode(['success' => true, 'data' => $rows]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}