proxitok/app/Controllers/TrendingController.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-30 23:02:52 +00: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 21:30:47 +00:00
$cursor = Misc::getTtwid();
2022-01-30 23:02:52 +00: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 23:02:52 +00: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-02-16 14:20:35 +00:00
$feed = $api->getTrendingFeed();
2022-01-30 23:02:52 +00:00
if ($feed->meta->success) {
$feed = RSS::build('/trending', 'Trending', 'Tiktok trending', $feed->items);
// Setup headers
RSS::setHeaders('trending.rss');
echo $feed;
}
}
}