你可以做的是使用一个php类,它需要你登录或注册你的网站。你可以从快速的Google找到很多。
然后,您应该在您的网站上创建一个API,只在您通过身份验证时才会发回数据。下面是会从MySQL数据库中读取数据为例:
<?php
require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/accounts.class.php"; //Change this to the path to your authentication script
header("Content-Type: application/json"); //Important if you're using json
$account = new Accounts(); //A fictional Accounts class is opened
$json = array();
if (!$account->authenticated or $account->rights != "administrator") { //Ask the class if the user is not an admin
$json = array(
"error" => "Not an administrator"
);
} else {
$query = mysqli_query($link, "SELECT * FROM example"); //Assuming you use mysqli and there's a table called example
if (!$query or mysqli_num_rows($query) < 1) {
$json = array(
"error" => "Query returned no results"
);
} else {
while ($row = mysqli_fetch_array($query)) { //Read the data from the table
$json[] = $row;
}
}
}
echo json_encode($json); //Send the data as a json string
记住上面的代码只是你会怎么做这类脚本的一个例子。您需要修改它以使用您正在使用的类和数据库。 现在,您可以为自己的内部使用制作自己的程序,用于登录并查询来自API的数据。这可能是运行在内部服务器,Windows程序或智能手机应用程序上的网站。它需要做的就是在网页上填写表单,然后发送HTTP请求到上面的脚本并解码json结果。
我认为你需要将你的问题改为几个子问题。目前,它应该广泛回答。 – Jacco
更改了这个问题,现在是: 你用什么来保护你的管理面板? –