Skip to content

Commit

Permalink
add json response type to api
Browse files Browse the repository at this point in the history
  • Loading branch information
leotsarev committed Dec 4, 2023
1 parent 64f1680 commit 09975e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions public_html/api/allrpg-info/find-by-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require_once 'funcs.php';
require_once 'logic/allrpg.php';

send_json_header();

$id = array_key_exists('id', $_GET) ? intval($_GET['id']) : '';
$result = get_game_by_allrpg_id($id);
if (is_array($result))
Expand Down
1 change: 1 addition & 0 deletions public_html/api/game/changed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_once 'logic/gamelist.php';
require_once 'api.php';

send_json_header();
$timestamp = get_request_field('timestamp');
$result = get_games_by_timestamp($timestamp);
if (is_array($result))
Expand Down
2 changes: 2 additions & 0 deletions public_html/api/game/get-by-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require_once 'logic/gamebase.php';
require_once 'api.php';

send_json_header();

$id = array_key_exists('id', $_GET) ? intval($_GET['id']) : '';
$result = get_game_by_id($id);
if (is_array($result))
Expand Down
5 changes: 5 additions & 0 deletions public_html/appcode/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ function strip_game_object_before_json($result)
}
return $response;
}

function send_json_header()
{
header('Content-Type: application/json; charset=utf-8');
}
?>

0 comments on commit 09975e5

Please sign in to comment.