당신이 할 수있는 일은 로그인하거나 웹 사이트에 가입해야하는 PHP 클래스를 사용하는 것입니다. 당신은 빠른 Google에서 충분히 찾을 수 있습니다.
인증을받은 경우 데이터를 다시 전송하는 API를 웹 사이트에 만들어야합니다.
<?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
위의 코드는 스크립트의 이런 종류의 작업을 수행 할 방법의 예입니다 기억 : 다음은 MySQL 데이터베이스에서 데이터를 읽을 것입니다 예입니다. 사용중인 클래스와 데이터베이스에서 작동하도록 수정해야합니다. 이제 API에 로그인하고 데이터를 쿼리하는 자신의 내부 용 프로그램을 만들 수 있습니다. 내부 서버, Windows 프로그램 또는 스마트 폰 앱에서 실행되는 웹 사이트 일 수 있습니다. 웹 페이지의 로그에 양식을 채운 다음 위의 스크립트에 HTTP 요청을 보내고 json 결과를 디코딩하면됩니다.
질문에 대한 몇 가지 질문을 다시 말해야 할 필요가 있다고 생각합니다. 현재, 대답하는 것은 넓습니다. – Jacco
질문을 변경했습니다 : 관리 패널을 보호하기 위해 무엇을 사용합니까? –