diff --git a/toreadapi.php b/toreadapi.php index 8874f16..e285134 100644 --- a/toreadapi.php +++ b/toreadapi.php @@ -330,5 +330,20 @@ function deleteEntry() { $data = $func(); header('Content-Type: application/json'); - echo json_encode($data); + $encoded = json_encode($data); + if (!$encoded) { + $data['links'] = array(array( + 'id' => json_last_error(), + 'title' => 'API ERROR: ' . json_last_error_msg(), + 'link' => 'http://php.net/manual/en/function.json-last-error.php', + 'description' => null, + 'time' => date('c'), + 'created' => time(), + 'deleted' => false, + 'tags' => array() + )); + $data['total'] = 1; + $encoded = json_encode($data); + } + echo $encoded; ?> \ No newline at end of file