Код: Выделить всё
$app->get('/acceptComplain/:user_id/:complain_id', 'acceptComplain');
Код: Выделить всё
http://localhost/ajmerpdss/acceptComplain/44/62546
В Postman ответом является ошибка 404 Not Found.
В браузере , я вижу сообщение «Объект не найден».
Определение функции для маршрута следующее:
Определение функции:
Код: Выделить всё
function acceptComplain($user_id, $complain_id) {
validateRequest(); // Token validation function
try {
$ComplainDAO = new ComplainDAO();
$SMSController = new SMSController();
$status = $ComplainDAO->acceptComplain($user_id, $complain_id);
if($status) {
$cmpArray = $ComplainDAO->getComplainDetailByComplainId($complain_id);
if(CUSTOMER_SMS == '1') {
$SMSController->customerComplainAcceptMessage($cmpArray['complain_number'], $cmpArray['customer_mobile'], $cmpArray['assignee_name'], $cmpArray['lineman_phone']);
}
}
if (!$status) {
$result['response'] = false;
$result['error_status'] = '1';
$result['status_message'] = "Error";
$result['display_message'] = "1";
$result['error_code'] = "004";
echo json_encode($result);
} else {
$result['response'] = true;
$result['error_status'] = '0';
$result['status_message'] = "Success";
$result['display_message'] = "1";
$result['error_code'] = "000";
echo json_encode($result);
}
} catch (PDOException $e) {
echo '{"error":{"text":' . $e->getMessage() . '}}';
}
}
Код: Выделить всё
function validateRequest() {
$headers = getallheaders();
try {
$token = trim($headers['TOKEN']); // Fetch the token from request headers
$UserDAO = new UserDAO();
$tokenRow = array();
if ($token != '') {
$tokenRow = $UserDAO->getUserByToken($token); // Validate token
}
if (!empty($tokenRow) && $tokenRow['user_id'] > 0) {
// Token is valid, proceed
} else {
// Token is invalid
$result['response'] = false;
$result['error_status'] = '1';
$result['status_message'] = "Invalid token";
$result['display_message'] = "1";
$result['error_code'] = "004";
echo json_encode($result);
die;
}
} catch (Exception $e) {
$result['response'] = false;
$result['error_status'] = '1';
$result['status_message'] = "Something goes wrong!";
$result['display_message'] = "1";
$result['error_code'] = "004";
echo json_encode($result);
die;
}
}
Код: Выделить всё
$app->get('/acceptComplain/:user_id/:complain_id', 'acceptComplain');
Я передал токен из базы данных как токен из заголовков, но по-прежнему получаю ту же проблему.
Я ожидаю разрешения моей жалобы, параметры которой передаются в программное обеспечение.
Я буду рад предоставить более подробную информацию, как только нужен
Подробнее здесь: https://stackoverflow.com/questions/793 ... -complaint
Мобильная версия