proxitok/app/Controllers/TrendingController.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-30 18:02:52 -05:00
<?php
namespace App\Controllers;
use App\Helpers\Misc;
use App\Models\FeedTemplate;
use App\Helpers\ErrorHandler;
use App\Helpers\RSS;
class TrendingController {
static public function get() {
2022-02-13 16:30:47 -05:00
$cursor = Misc::getTtwid();
2022-01-30 18:02:52 -05:00
$api = Misc::api();
// Ttwid if normal, cursor if legacy
if ($api::class === 'TikScraper\Api') {
$cursor = Misc::getTtwid();
} else {
$cursor = Misc::getCursor();
}
$feed = $api->getTrending($cursor);
2022-01-30 18:02:52 -05:00
if ($feed->meta->success) {
$latte = Misc::latte();
$latte->render(Misc::getView('trending'), new FeedTemplate('Trending', $feed));
} else {
ErrorHandler::show($feed->meta);
}
}
static public function rss() {
$api = Misc::api();
2022-03-11 17:24:13 -05:00
$feed = $api->getTrending();
2022-01-30 18:02:52 -05:00
if ($feed->meta->success) {
$feed = RSS::build('/trending', 'Trending', 'Tiktok trending', $feed->items);
// Setup headers
RSS::setHeaders('trending.rss');
echo $feed;
}
}
}