0
I made this class in order to create a JSON to return in my Web Service, but it’s not working, someone would know why?
Class Uteis
<?php
class Uteis {
public static function criarjson($mensagem,$value){
$json_str = '{"autenticado":$value, "mensagem":$mensagem}';
$json = json_decode($json_str);
return json_encode($json);
}
}
?>
Index.php
$app->post('/login',function(Request $request,Response $response){
$allquery = $request->getQueryParams();
$user = new Usuario();
$sql = new Sql();
$autenticado = $user->login($allquery['login'],$allquery['senha']);
if ($autenticado) {
$response = Uteis::criarjson("AA",true);
}else{
$response = Uteis::criarjson("Erro ao autenticar",false);
}
return $response;
});
$app->run();
Worked thanks
– Igor Oliveira
I’m glad it worked out
– adventistaam