Files
whatsapp/api/delete_template.php
T
2026-01-21 02:22:29 -05:00

26 lines
759 B
PHP

<?php
require_once __DIR__ . '/../config/config_enhanced.php';
require_once __DIR__ . '/../config/config.php';
header('Content-Type: application/json; charset=utf-8');
if (function_exists('requireAuthentication')) requireAuthentication();
$input = json_decode(file_get_contents('php://input'), true) ?: $_POST;
$id = intval($input['id'] ?? 0);
if (!$id) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'id is required']);
exit;
}
try {
$db = Database::getInstance();
$db->execute("DELETE FROM message_templates WHERE id = ?", [$id]);
echo json_encode(['success' => true]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}