[FEAT] Add API to read the list of scores
This commit is contained in:
26
api/score/read.php
Normal file
26
api/score/read.php
Normal 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);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user