mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-26 04:51:08 -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'))
|
if (!$this->input->post('text'))
|
||||||
{
|
{
|
||||||
$data['data'] = array(
|
$data['msg'] = 'Error: Missing paste text';
|
||||||
'error' => 'missing paste text',
|
|
||||||
);
|
|
||||||
$this->load->view('view/api', $data);
|
$this->load->view('view/api', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -47,9 +45,7 @@ class Api extends Main
|
|||||||
}
|
}
|
||||||
$_POST['code'] = $this->input->post('text');
|
$_POST['code'] = $this->input->post('text');
|
||||||
$paste_url = $this->pastes->createPaste();
|
$paste_url = $this->pastes->createPaste();
|
||||||
$data['data'] = array(
|
$data['msg'] = base_url() . $paste_url;
|
||||||
'url' => base_url() . $paste_url,
|
|
||||||
);
|
|
||||||
$this->load->view('view/api', $data);
|
$this->load->view('view/api', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
<h2>Return values</h2>
|
<h2>Return values</h2>
|
||||||
<p class="explain">
|
<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 success, the API returns the paste URL: <code><?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 error, the API returns the error message: <code>Error: Missing paste text</code>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>POST parameters</h2>
|
<h2>POST parameters</h2>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
echo json_encode($data);
|
echo $msg . "\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user