Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用React Native和Php隐藏json数据_Php_React Native - Fatal编程技术网

使用React Native和Php隐藏json数据

使用React Native和Php隐藏json数据,php,react-native,Php,React Native,我的应用程序使用React Native和Php。Php从mysql返回json数据。但如果用户在google中输入我的获取url,他可以看到我的json数据。如何隐藏我的数据 $json = file_get_contents('php://input'); $result = mysqli_query($link, "SELECT * FROM news"); if(mysqli_num_rows($result)) { while($row[] = mysq

我的应用程序使用React Native和Php。Php从mysql返回json数据。但如果用户在google中输入我的获取url,他可以看到我的json数据。如何隐藏我的数据

$json = file_get_contents('php://input');

$result = mysqli_query($link, "SELECT * FROM news");

if(mysqli_num_rows($result)) {
    while($row[] = mysqli_fetch_assoc($result)) {
        $json = json_encode($row);
    }
}else {
    echo 'connection error';
}

所有可以在浏览器中完成的事情,用户可以通过浏览器的开发工具手动完成。因此,“隐藏”数据不是正确的解决方案

我的建议是:

  • ,这将帮助您通过在浏览器地址栏中插入URL来避免直接访问(因此,是的,您可以对直接访问“隐藏”数据,但这并不能解决全局安全问题)

  • 添加身份验证。如果任何用户都可以访问您的数据库,这就是全局安全问题。至少,添加或基本身份验证。在其他情况下,添加。这将只允许特定用户访问您的数据。这比“隐藏”直接访问要好得多,也更安全

  • !!这很重要,可以帮助您避免SQL注入问题