Web service for web / android

0

I have the following web service

$app->get('/alunos', function(){
require_once('db/config.php');
foreach ($db->alunos()
             ->order("nome")
         as $row){
    $data[]=$row;
}

echo  json_encode($data, JSON_UNESCAPED_UNICODE); //para android

$loader = new Twig_Loader_Filesystem('views/alunos/');

$twig = new Twig_Environment($loader, array());

$template = $twig->loadTemplate('registar.php');
echo $template->render(array('data' => $data)); //para web
});

Does anyone know how I can show the correct webservice for android / web and not both.

    
asked by anonymous 07.01.2018 / 13:43

1 answer

1

You have to pass a parameter during the request, informing which webservice you want to access. It would be a half mouth alternative, even better would be to have a webservice for each device as it allows you to customize them independently.

Or, even more half-mouthed, check if who is accessing is a mobile device and treat it, a tool that can do this is the link

    
07.01.2018 / 15:41