mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 12:31:06 -05:00
#102: recent and trending for the API
This commit is contained in:
parent
9882c00a3f
commit
5341c7901d
@ -7,6 +7,8 @@
|
||||
* - create()
|
||||
* - paste()
|
||||
* - random()
|
||||
* - recent()
|
||||
* - trending()
|
||||
* Classes list:
|
||||
* - Api extends Main
|
||||
*/
|
||||
@ -102,4 +104,43 @@ class Api extends Main
|
||||
$data = $this->pastes->random_paste();
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
function recent()
|
||||
{
|
||||
$this->load->model('pastes');
|
||||
$pastes = $this->pastes->getLists();
|
||||
$pastes = $pastes['pastes'];
|
||||
$data = array();
|
||||
foreach ($pastes as $paste)
|
||||
{
|
||||
$data[] = array(
|
||||
'pid' => $paste['pid'],
|
||||
'title' => $paste['title'],
|
||||
'name' => $paste['name'],
|
||||
'created' => $paste['created'],
|
||||
'lang' => $paste['lang'],
|
||||
);
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
function trending()
|
||||
{
|
||||
$this->load->model('pastes');
|
||||
$pastes = $this->pastes->getTrends();
|
||||
$pastes = $pastes['pastes'];
|
||||
$data = array();
|
||||
foreach ($pastes as $paste)
|
||||
{
|
||||
$data[] = array(
|
||||
'pid' => $paste['pid'],
|
||||
'title' => $paste['title'],
|
||||
'name' => $paste['name'],
|
||||
'created' => $paste['created'],
|
||||
'lang' => $paste['lang'],
|
||||
'hits' => $paste['hits'],
|
||||
);
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user