test-php-rest-api-user/engine/core/api/v1/getUser.php

28 lines
524 B
PHP
Raw Normal View History

2024-08-10 00:45:57 +08:00
<?php
2024-08-10 00:53:15 +08:00
if($_SERVER['REQUEST_METHOD'] == 'GET') {
if(!isset($_REQUEST['login'])) {
$data = [
'error' => true,
'message' => 'Не передано поле login',
];
}
elseif(!$user = User::get($_REQUEST['login'])) {
$data = [
'error' => true,
'message' => 'Пользователь не существует',
];
}
else {
$data = [
'error' => false,
'data' => $user,
];
}
2024-08-10 00:45:57 +08:00
}
else {
$data = [
2024-08-10 00:53:15 +08:00
'error' => true,
'message' => 'Только метод GET',
2024-08-10 00:45:57 +08:00
];
}