Pages support
This commit is contained in:
parent
fa632b1f2d
commit
c8d991883a
|
@ -12,8 +12,7 @@ php -S localhost:8080
|
|||
```
|
||||
|
||||
## Known issues
|
||||
* Right now there is an error when trying to fetch the desired user, there is already a pull request fixing this issue on the TikTokApi repo, you can check it out [here](https://github.com/ssovit/TikTok-API-PHP/pull/43)
|
||||
* Only one page is available to the user
|
||||
* Right now there is an error when trying to fetch the desired user, there is already a pull request not merged yet fixing this issue on the TikTokApi repo, you can check it out [here](https://github.com/ssovit/TikTok-API-PHP/pull/43)
|
||||
|
||||
## Credits
|
||||
* [TikTok-API-PHP](https://github.com/ssovit/TikTok-API-PHP)
|
||||
|
|
|
@ -10,9 +10,13 @@ $app->get('/', function () use ($app) {
|
|||
});
|
||||
|
||||
$app->get("/users/{user}", function (string $username) {
|
||||
$cursor = 0;
|
||||
if (isset($_GET['cursor']) && is_numeric($_GET['cursor'])) {
|
||||
$cursor = (int) $_GET['cursor'];
|
||||
}
|
||||
$blade = new Blade('./views', './cache/views');
|
||||
$api = new \Sovit\TikTok\Api();
|
||||
$user = $api->getUserFeed($username);
|
||||
$user = $api->getUserFeed($username, $cursor);
|
||||
if ($user) {
|
||||
echo $blade->render('user', ['user' => $user]);
|
||||
} else {
|
||||
|
|
|
@ -34,6 +34,14 @@
|
|||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a class="button" href="javascript:history.back()">Last page</a>
|
||||
@if ($user->hasMore)
|
||||
<a class="button" href="?cursor={{ $user->maxCursor }}">Next page</a>
|
||||
@else
|
||||
<a class="button is-disabled">Next page</a>
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
<div id="modal" class="modal">
|
||||
<div id="modal-background" class="modal-background"></div>
|
||||
|
|
Loading…
Reference in a new issue