2022-01-01 14:14:57 -05:00
|
|
|
<?php
|
|
|
|
require __DIR__ . "/vendor/autoload.php";
|
|
|
|
|
|
|
|
use Leaf\Blade;
|
|
|
|
|
|
|
|
$app = new Leaf\App;
|
|
|
|
|
|
|
|
$app->get('/', function () use ($app) {
|
|
|
|
$app->response()->page('./views/home.html');
|
|
|
|
});
|
|
|
|
|
2022-01-01 18:06:00 -05:00
|
|
|
$app->get('/stream', function () {
|
|
|
|
if (!isset($_GET['url'])) {
|
|
|
|
die('You need to send a url!');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start streamer
|
|
|
|
$streamer = new \Sovit\TikTok\Stream();
|
|
|
|
$streamer->stream($_GET['url']);
|
|
|
|
});
|
|
|
|
|
|
|
|
$app->get("/@([^/]+)", function (string $username) {
|
2022-01-01 14:48:42 -05:00
|
|
|
$cursor = 0;
|
|
|
|
if (isset($_GET['cursor']) && is_numeric($_GET['cursor'])) {
|
|
|
|
$cursor = (int) $_GET['cursor'];
|
|
|
|
}
|
2022-01-01 14:14:57 -05:00
|
|
|
$blade = new Blade('./views', './cache/views');
|
|
|
|
$api = new \Sovit\TikTok\Api();
|
2022-01-01 14:48:42 -05:00
|
|
|
$user = $api->getUserFeed($username, $cursor);
|
2022-01-01 14:14:57 -05:00
|
|
|
if ($user) {
|
|
|
|
echo $blade->render('user', ['user' => $user]);
|
|
|
|
} else {
|
|
|
|
echo 'ERROR!';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$app->run();
|