mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
api with json return
This commit is contained in:
parent
d162fb1284
commit
2e82df600a
@ -23,11 +23,24 @@ class Api extends Main
|
|||||||
|
|
||||||
if (!$this->input->post('text'))
|
if (!$this->input->post('text'))
|
||||||
{
|
{
|
||||||
echo 'missing paste text';
|
$data['data'] = array(
|
||||||
|
'error' => 'missing paste text',
|
||||||
|
);
|
||||||
|
$this->load->view('view/api', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo $this->pastes->createPaste();
|
|
||||||
|
if (!$this->input->post('lang'))
|
||||||
|
{
|
||||||
|
$_POST['lang'] = 'text';
|
||||||
|
}
|
||||||
|
$_POST['code'] = $this->input->post('text');
|
||||||
|
$paste_url = $this->pastes->createPaste();
|
||||||
|
$data['data'] = array(
|
||||||
|
'url' => base_url() . $paste_url,
|
||||||
|
);
|
||||||
|
$this->load->view('view/api', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
htdocs/application/views/view/api.php
Executable file
3
htdocs/application/views/view/api.php
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
echo json_encode($data);
|
@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
header('Content-Type:text/plain; charset=utf-8');
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
echo htmlspecialchars_decode($raw);
|
echo htmlspecialchars_decode($raw);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user