-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathuser.php
More file actions
29 lines (22 loc) · 759 Bytes
/
Copy pathuser.php
File metadata and controls
29 lines (22 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$user = (require __DIR__ . "/../dic/users.php")->getById($_GET["id"]);
if ($user === null) {
http_response_code(404);
return;
}
$tweetsService = (require __DIR__ . "/../dic/tweets.php");
$tweets = $tweetsService->getLastByUser($_GET["id"]);
$tweetsCount = $tweetsService->getTweetsCount($_GET["id"]);
switch (require __DIR__ . "/../dic/negotiated_format.php") {
case "text/html":
(new Views\Layout(
"Tweets from @$_GET[id]",
new Views\Tweets\Listing($user, $tweets, $tweetsCount)
))();
exit;
case "application/json":
header("Content-Type: application/json");
echo json_encode(["count" => $tweetsCount, "last20" => $tweets]);
exit;
}
http_response_code(406);