[FEAT] Add API to read the list of scores

This commit is contained in:
2020-11-12 22:21:52 +01:00
parent cf38fa26d7
commit 1579e54c09
5 changed files with 142 additions and 0 deletions

26
api/score/read.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
// include database and object files
include_once '../config/database.php';
include_once '../objects/score.php';
// instantiate database and score object
$db = new Database();
// initialize object
$score = new Score($db, "../../Scores/");
// read score will be here
// query scores
$scores_arr = $score->read_score_list();
// set response code - 200 OK
http_response_code(200);
// show scores data in json format
echo json_encode($scores_arr);
?>