Skip to content

Commit 3197c20

Browse files
committed
fortnite challenges website with fortnite tracker api
1 parent 178da36 commit 3197c20

4 files changed

Lines changed: 86 additions & 0 deletions

File tree

109 KB
Binary file not shown.

fortnite_challenges/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+
?>

fortnite_challenges/functions.php

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/challenges
5+
function getChalleges() {
6+
$apiUrlEndpoint = 'https://api.fortnitetracker.com/v1/challenges';
7+
8+
$ch = curl_init();
9+
10+
curl_setopt( $ch, CURLOPT_URL, $apiUrlEndpoint );
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_challenges/index.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
include 'functions.php';
3+
4+
$challenges = getChalleges();
5+
6+
// echo '<pre>';
7+
// print_r( $challenges );
8+
// die();
9+
?>
10+
<!DOCTYPE html>
11+
<html>
12+
<head>
13+
<title>Fortnite Current Active Challenges</title>
14+
<meta charset="utf-8" />
15+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
16+
<style>
17+
@font-face {
18+
font-family: 'Fortnite';
19+
src: url( 'BurbankBigCondensed-Bold.otf' );
20+
}
21+
22+
body {
23+
font-family: 'Fortnite';
24+
background: #1e1e1e;
25+
color: #fff;
26+
padding: 10px;
27+
}
28+
</style>
29+
</head>
30+
<body>
31+
<div style="margin-bottom:20px;font-size:48px">
32+
<div style="text-transform: uppercase">Fortnite Current Active Challenges</div>
33+
</div>
34+
<div style="width:100%;color:#000;background:#f1ed62;font-size:26px;display:inline-block">
35+
<div style="padding:5px">
36+
<div style="float:left">CHALLEGES</div>
37+
</div>
38+
</div>
39+
<ul style="list-style: none;padding:0px;margin:0px;margin:0px;margin-bottom:20px">
40+
<?php foreach ( $challenges['items'] as $challenge ) : ?>
41+
<li style="border:3px solid #363636;padding:10px;margin-top:20px">
42+
<div style="display:inline-block;width:100%;">
43+
<?php foreach ( $challenge['metadata'] as $data ) : ?>
44+
<?php if ( 'rewardPictureUrl' == $data['key'] ) : ?>
45+
<div style="display:inline-block;float:left">
46+
<img style="display:block;width:50px" src="<?php echo $data['value']; ?>" />
47+
</div>
48+
<?php elseif ( 'name' == $data['key'] ) : ?>
49+
<div style="font-size:30px;display:inline-block;margin-left:20px;width:calc(100%-100px)">
50+
<?php echo $data['value']; ?>
51+
</div>
52+
<?php endif; ?>
53+
<?php endforeach; ?>
54+
</div>
55+
</li>
56+
<?php endforeach; ?>
57+
</ul>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)