-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
36 lines (34 loc) · 1.14 KB
/
example.php
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
30
31
32
33
34
35
36
<html>
<head>
<title>Canv.as stats example</title>
</head>
<body>
<?php
if (!isset($_GET["user"])) { ?>
<form method="GET">
<input type="text" name="user" placeholder="Canvas username">
<input type="submit">
</form>
<?php
} else {
$user = htmlspecialchars($_GET["user"]);
include("CanvasStats.php");
$canvas_stats = new CanvasStats($user);
if ($canvas_stats->error()){
die($canvas_stats->error());
}
echo "<h1>Sticker list:</h1>\r\n";
echo "<ul>";
foreach($canvas_stats->getAllStickers() as $type => $amount) {
echo "<li><b>$type:</b> $amount</li>\r\n";
}
echo "</ul>\r\n\r\n";
echo "<h1>Additional stats:</h1>\r\n";
echo "<p><b>Number of stickers:</b> ".$canvas_stats->getNumStickers()."</p>\r\n";
echo "<p><b>Number of posts:</b> ".$canvas_stats->getNumPosts()."</p>\r\n";
echo "<p><b>Total points:</b> ".$canvas_stats->getPoints()."</p>\r\n";
echo "<p><b>Average points per post:</b> ".$canvas_stats->getAvgPoints()."</p>\r\n";
echo "<p><i>A total of ".$canvas_stats->getApiCalls()." calls to Canv.as api were needed to get these stats.</i></p>\r\n";
}?>
</body>
</html>