<?php
const AUTH_TOKEN = 'VotreTokenSecret123';
if (!isset(getallheaders()['Authorization']) || getallheaders()['Authorization'] !== 'Bearer ' . AUTH_TOKEN) {
header('HTTP/1.1 401 Unauthorized');
exit('Accès non autorisé');
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('HTTP/1.1 405 Method Not Allowed');
exit('Méthode non autorisée');
}
$lastname = $_POST['lastname'] ?? null;
$firstname = $_POST['firstname'] ?? null;
$phone = $_POST['phone'] ?? null;
$email = $_POST['email'] ?? null;
header('Content-Type: application/json');
$response = [
'status' => 'success',
'data' => [
'lastname' => $lastname,
'firstname' => $firstname,
'phone' => $phone,
'email' => $email
]
];
echo json_encode($response);