Skip to content

Commit 178da36

Browse files
committed
create a fortnite player stats website
1 parent b9fdf49 commit 178da36

4 files changed

Lines changed: 180 additions & 0 deletions

File tree

109 KB
Binary file not shown.

fortnite_player_stats/config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
define( 'FN_API_KEY', 'YOUR-API-KEY-HERE' );
3+
?>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
include 'config.php';
3+
4+
// https://api.fortnitetracker.com/v1/profile/{platform}/{epic-nickname}
5+
function getPlayerStats( $platform, $epicNickname ) {
6+
$apiUrlPlayerStatsEndpoint = 'https://api.fortnitetracker.com/v1/profile/' . $platform . '/' . $epicNickname;
7+
8+
$ch = curl_init();
9+
10+
curl_setopt( $ch, CURLOPT_URL, $apiUrlPlayerStatsEndpoint );
11+
12+
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
13+
'TRN-Api-Key:' . FN_API_KEY
14+
) );
15+
16+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
17+
curl_setopt( $ch, CURLOPT_HEADER, FALSE );
18+
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
19+
20+
$response = curl_exec( $ch );
21+
curl_close( $ch );
22+
23+
return json_decode( $response, true );
24+
}

fortnite_player_stats/index.php

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
include 'functions.php';
3+
4+
$platform = 'pc';
5+
$epicNickname = 'jstolpe';
6+
7+
$playerStats = getPlayerStats( $platform, $epicNickname );
8+
9+
// echo '<pre>';
10+
// print_r( $playerStats );
11+
// die();
12+
?>
13+
<!DOCTYPE html>
14+
<html>
15+
<head>
16+
<title>Fortnite Player Stats</title>
17+
<meta charset="utf-8" />
18+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
19+
<style>
20+
@font-face {
21+
font-family: 'Fortnite';
22+
src: url( 'BurbankBigCondensed-Bold.otf' );
23+
}
24+
25+
body {
26+
font-family: 'Fortnite';
27+
background: #1e1e1e;
28+
color: #fff;
29+
padding: 10px;
30+
}
31+
</style>
32+
</head>
33+
<body>
34+
<div style="margin-bottom:20px;font-size:48px">
35+
<div>FORTNITE PLAYER STATS</div>
36+
<div style="font-size:28px;">
37+
Player <?php echo $epicNickname; ?> on <?php echo $platform; ?>
38+
</div>
39+
</div>
40+
<div style="width:100%;color:#000;background:#f1ed62;font-size:26px;display:inline-block">
41+
<div style="padding:5px">
42+
<div style="float:left">LIFETIME</div>
43+
</div>
44+
</div>
45+
<ul style="list-style: none;padding:0px;margin:0px;margin:0px;margin-bottom:20px">
46+
<?php foreach ( $playerStats['lifeTimeStats'] as $stat ) : ?>
47+
<li style="display:inline-block;border:1px solid #363636;padding:10px;margin-left:10px;margin-top:10px">
48+
<div>
49+
<div style="color:#9a9a9a;font-size: 16px;">
50+
<?php echo $stat['key']; ?>
51+
</div>
52+
<div style="font-size:22px">
53+
<?php echo $stat['value']; ?>
54+
</div>
55+
</div>
56+
</li>
57+
<?php endforeach; ?>
58+
</ul>
59+
<div style="width:100%;color:#000;background:#f1ed62;font-size:26px;display:inline-block">
60+
<div style="padding:5px">
61+
<div style="float:left">SOLOS</div>
62+
</div>
63+
</div>
64+
<ul style="list-style: none;padding:0px;margin:0px;margin:0px;margin-bottom:20px">
65+
<?php foreach ( $playerStats['stats']['p2'] as $stat ) : ?>
66+
<?php if ( $stat['value'] ) : ?>
67+
<li style="display:inline-block;border:1px solid #363636;padding:10px;margin-left:10px;margin-top:10px">
68+
<div>
69+
<div style="color:#9a9a9a;font-size: 16px;">
70+
<?php echo $stat['label']; ?>
71+
</div>
72+
<div style="font-size:22px">
73+
<?php echo $stat['displayValue']; ?>
74+
</div>
75+
<div style="color:#9a9a9a;font-size:14px;margin-top:5px;">
76+
Rank
77+
</div>
78+
<div style="font-size:18px">
79+
<?php if ( isset( $stat['rank'] ) ) : ?>
80+
#<?php echo number_format( $stat['rank'] ); ?>
81+
<?php else : ?>
82+
-
83+
<?php endif; ?>
84+
</div>
85+
</div>
86+
</li>
87+
<?php endif; ?>
88+
<?php endforeach; ?>
89+
</ul>
90+
<div style="width:100%;color:#000;background:#f1ed62;font-size:26px;display:inline-block">
91+
<div style="padding:5px">
92+
<div style="float:left">DUOS</div>
93+
</div>
94+
</div>
95+
<ul style="list-style: none;padding:0px;margin:0px;margin:0px;margin-bottom:20px">
96+
<?php foreach ( $playerStats['stats']['p10'] as $stat ) : ?>
97+
<?php if ( $stat['value'] ) : ?>
98+
<li style="display:inline-block;border:1px solid #363636;padding:10px;margin-left:10px;margin-top:10px">
99+
<div>
100+
<div style="color:#9a9a9a;font-size: 16px;">
101+
<?php echo $stat['label']; ?>
102+
</div>
103+
<div style="font-size:22px">
104+
<?php echo $stat['displayValue']; ?>
105+
</div>
106+
<div style="color:#9a9a9a;font-size:14px;margin-top:5px;">
107+
Rank
108+
</div>
109+
<div style="font-size:18px">
110+
<?php if ( isset( $stat['rank'] ) ) : ?>
111+
#<?php echo number_format( $stat['rank'] ); ?>
112+
<?php else : ?>
113+
-
114+
<?php endif; ?>
115+
</div>
116+
</div>
117+
</li>
118+
<?php endif; ?>
119+
<?php endforeach; ?>
120+
</ul>
121+
<div style="width:100%;color:#000;background:#f1ed62;font-size:26px;display:inline-block">
122+
<div style="padding:5px">
123+
<div style="float:left">SQUADS</div>
124+
</div>
125+
</div>
126+
<ul style="list-style: none;padding:0px;margin:0px;margin:0px;margin-bottom:20px">
127+
<?php foreach ( $playerStats['stats']['p9'] as $stat ) : ?>
128+
<?php if ( $stat['value'] ) : ?>
129+
<li style="display:inline-block;border:1px solid #363636;padding:10px;margin-left:10px;margin-top:10px">
130+
<div>
131+
<div style="color:#9a9a9a;font-size: 16px;">
132+
<?php echo $stat['label']; ?>
133+
</div>
134+
<div style="font-size:22px">
135+
<?php echo $stat['displayValue']; ?>
136+
</div>
137+
<div style="color:#9a9a9a;font-size:14px;margin-top:5px;">
138+
Rank
139+
</div>
140+
<div style="font-size:18px">
141+
<?php if ( isset( $stat['rank'] ) ) : ?>
142+
#<?php echo number_format( $stat['rank'] ); ?>
143+
<?php else : ?>
144+
-
145+
<?php endif; ?>
146+
</div>
147+
</div>
148+
</li>
149+
<?php endif; ?>
150+
<?php endforeach; ?>
151+
</ul>
152+
</body>
153+
</html>

0 commit comments

Comments
 (0)