simpler API response

This commit is contained in:
Claude 2012-05-08 17:20:13 +02:00
parent 84f9b3b2b8
commit 4bd59673f1
3 changed files with 5 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -9,8 +9,8 @@
<h2>Return values</h2>
<p class="explain">
On success, the API returns the paste URL in JSON format: <code>{"url":"<?php echo site_url('view/[pasteid]'); ?>"}</code><br />
On error, the API returns the error message in JSON format: <code>{"error":"missing paste text"}</code>
On success, the API returns the paste URL: <code><?php echo site_url('view/[pasteid]'); ?></code><br />
On error, the API returns the error message: <code>Error: Missing paste text</code>
</p>
<h2>POST parameters</h2>

View File

@ -1,3 +1,3 @@
<?php
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
echo $msg . "\n";