簡體   English   中英

安全的移動應用程序連接到服務器

[英]Secure mobile apps connection to server

我正在使用 web 技術(例如 Java 腳本)創建移動應用程序。 我的服務器正在運行 php 以連接到數據庫。 如果我想在數據庫中插入/刪除/更新某些內容,則需要通過 Ajax 傳遞信息。 我知道使用該應用程序時沒有人可以看到源代碼,但是如果有人可以通過某種方式獲取源代碼,我該如何防止用戶看到我的服務器地址和 php 文件名?

示例代碼(來自 w3schools):

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById("txtHint").innerHTML = this.responseText;
  }
};
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();

我找到了一個方法

    <div id="testeFuncao">
        <script type="text/javascript">
            $("#butaoTeste").on("click", function(){
                var xmlhttp = new XMLHttpRequest();
                xmlhttp.onreadystatechange = function() {
                if (this.readyState == 4 && this.status == 200) {
                    document.getElementById("txtHint").innerHTML = this.responseText;
                }
                };
                xmlhttp.open("GET", "gethint.php?q=" + str, true);
                xmlhttp.send();
            });

            $("#testeFuncao").remove();
        </script>
    </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM