What method to use to not show the json data on the php page that serves as a request for android app

Asked

Viewed 43 times

0

Good evening, I have an android app and I am using this php code for the request of a json and I wish that the data would not appear when someone used the url, because so can see the exit information of select

How could I do not show and manage to request the data in the app?

<?php

// APK WebService CRUD

ini_set('default_charset', 'utf-8');

require_once('config.inc.php');

$sql = 'SELECT * FROM `contato`';

$statement = $connection->prepare($sql);

$statement->execute();

if($statement->rowCount()) {
  $row_all = $statement->fetchall(PDO::FETCH_ASSOC);

  header('Content-type: application/json');

  echo json_encode($row_all);

} elseif (!$statement->rowCount()) {
  echo "sem linhas";
}

?>

Exit:

[{"id":"6","nome":"micael","email":"mica@b"},{"id":"7","nome":"agusto","email":"a@b"},{"id":"8","nome":"alma","email":"c@hotmail"}] 

from now on thank you

  • 4

    You should then use some form of authentication, so that only authenticated users could have any results from the web-service query. I know of no other method than trickery or deception.

  • As Jefferson has said, there is no way, at least not without encryption or some method of authentication to access the webservice. Or, last but not least, if you’re on a service at specific locations with specific machines, you can only authorize certain sources to request to receive json.

  • You may even make it difficult, but in all cases you will have access to content outside the application. In addition, you may, in the terms of use, declare that you cannot access such content outside of the application, "unthinkable" that uses such an API outside of the application, this is a legal issue, not programming. In general, this is not a problem.

No answers

Browser other questions tagged

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