From 4bd59673f1cdc2525f4e2e9e6214b0e24549a324 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 8 May 2012 17:20:13 +0200 Subject: [PATCH] simpler API response --- htdocs/application/controllers/api.php | 8 ++------ htdocs/application/views/api_help.php | 4 ++-- htdocs/application/views/view/api.php | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/application/controllers/api.php b/htdocs/application/controllers/api.php index 3ecee9a..47b8e5e 100755 --- a/htdocs/application/controllers/api.php +++ b/htdocs/application/controllers/api.php @@ -33,9 +33,7 @@ class Api extends Main if (!$this->input->post('text')) { - $data['data'] = array( - 'error' => 'missing paste text', - ); + $data['msg'] = 'Error: Missing paste text'; $this->load->view('view/api', $data); } else @@ -47,9 +45,7 @@ class Api extends Main } $_POST['code'] = $this->input->post('text'); $paste_url = $this->pastes->createPaste(); - $data['data'] = array( - 'url' => base_url() . $paste_url, - ); + $data['msg'] = base_url() . $paste_url; $this->load->view('view/api', $data); } } diff --git a/htdocs/application/views/api_help.php b/htdocs/application/views/api_help.php index c91fae3..43982c8 100755 --- a/htdocs/application/views/api_help.php +++ b/htdocs/application/views/api_help.php @@ -9,8 +9,8 @@

Return values

- On success, the API returns the paste URL in JSON format: {"url":""}
- On error, the API returns the error message in JSON format: {"error":"missing paste text"} + On success, the API returns the paste URL:
+ On error, the API returns the error message: Error: Missing paste text

POST parameters

diff --git a/htdocs/application/views/view/api.php b/htdocs/application/views/view/api.php index 07689db..1a7ef07 100755 --- a/htdocs/application/views/view/api.php +++ b/htdocs/application/views/view/api.php @@ -1,3 +1,3 @@