mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
simpler API response
This commit is contained in:
parent
84f9b3b2b8
commit
4bd59673f1
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($data);
|
||||
echo $msg . "\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user