proxitok/app/Controllers/TrendingController.php
2022-05-24 14:10:41 +02:00

44 lines
1.2 KiB
PHP

<?php
namespace App\Controllers;
use App\Helpers\Misc;
use App\Models\FeedTemplate;
use App\Helpers\ErrorHandler;
use App\Helpers\Wrappers;
use App\Models\RSSTemplate;
class TrendingController {
static public function get() {
$api = Wrappers::api();
// Ttwid if standard, cursor if legacy
if ($api->isLegacy()) {
$cursor = Misc::getCursor();
} else {
$cursor = Misc::getTtwid();
}
$trending = $api->trending();
$trending->feed($cursor);
$feed = $trending->getFeed();
if ($feed && $feed->meta->success) {
$latte = Wrappers::latte();
$latte->render(Misc::getView('trending'), new FeedTemplate('Trending', $feed));
} else {
ErrorHandler::show($trending->error());
}
}
static public function rss() {
$api = Wrappers::api();
$trending = $api->trending();
$trending->feed();
$feed = $trending->getFeed();
if ($feed && $feed->meta->success) {
$latte = Wrappers::latte();
$latte->render(Misc::getView('rss'), new RSSTemplate('Trending', 'Trending on TikTok', '/trending', $feed->items));
}
}
}