Use output function to handle headers and json encoding
This commit is contained in:
parent
6150f113c9
commit
e4763b3e0b
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
define('IN_SCRIPT', 1);
|
define('IN_SCRIPT', 1);
|
||||||
define('HESK_PATH', '../../');
|
define('HESK_PATH', '../../');
|
||||||
|
define('API_PATH', '../');
|
||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
require(HESK_PATH . 'inc/common.inc.php');
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
|
require(API_PATH . 'core/output.php');
|
||||||
|
|
||||||
hesk_load_api_database_functions();
|
hesk_load_api_database_functions();
|
||||||
hesk_dbConnect();
|
hesk_dbConnect();
|
||||||
@ -18,9 +20,7 @@ if (isset($_GET['id'])) {
|
|||||||
$result['title'] = hesk_html_entity_decode($result['title']);
|
$result['title'] = hesk_html_entity_decode($result['title']);
|
||||||
$result['message'] = hesk_html_entity_decode($result['message']);
|
$result['message'] = hesk_html_entity_decode($result['message']);
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
output($result);
|
||||||
print json_encode($result);
|
|
||||||
return http_response_code(200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = hesk_dbQuery("SELECT `id`, `message`, `title`, `reply_order` FROM `"
|
$response = hesk_dbQuery("SELECT `id`, `message`, `title`, `reply_order` FROM `"
|
||||||
|
7
api/core/output.php
Normal file
7
api/core/output.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function output($data, $status_code = 200) {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
print json_encode($data);
|
||||||
|
return http_response_code($status_code);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user