Fortnite Tracker is a third-party service that creates an API endpoint for the Fortnite game. Here is a guide on getting your player stats, however in this post i will show how to access the Fortnite store with PHP through Fortnite Tracker API.
The first step like last time is to call the API and save it into a JSON file, this can be done like so with the use of Curl and fwrite
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fortnitetracker.com/v1/store");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'TRN-Api-Key: *API*KEY*HERE*'
));
$response = curl_exec($ch);
curl_close($ch);
$fp = fopen("stats.json", "w");
fwrite($fp, $response);
fclose($fp); Remember to add your Fortnite Tracker API key in!
The easiest way to check if the API call worked is to run the following code, which will loop through the data and output the image, item name, rarity and vbucks price in a formatted manner.
$response = json_decode(file_get_contents('stats.json'), true);
foreach ($response as $val) {
$image = $val['imageUrl'];
$item = $val['name'];
$rarity = $val['rarity'];
$vbucks = $val['vBucks'];
echo " $item | Rarity: $rarity vBucks: $vbucks
";
} You can see from the above code how each of the objects was accessed. If you wanted to store the values in a database instead of outputting the data you would insert using the variables.
Below is a spoiler of the raw Fortnite Tracker API call and yes it only has 10 items at this time.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…