Web service for web/android

Asked

Viewed 40 times

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.

1 answer

1


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

Or, even more half mouth, check if who is accessing it is a mobile device and treat this, a tool that can do this is the http://mobiledetect.net/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.