PHP code example of iaretedd / fortnite-api

1. Go to this page and download the library: Download iaretedd/fortnite-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iaretedd / fortnite-api example snippets




ortnite\Auth;
use Fortnite\Account;
use Fortnite\Mode;
use Fortnite\Language;
use Fortnite\Platform;

// Authenticate
$auth = Auth::login('[email protected]','password');

// Output each stat for all applicable platforms
var_dump($auth->profile->stats);

// Grab someone's stats
$sandy = $auth->profile->stats->lookup('sandalzrevenge');
echo 'Sandy Ravage has won ' . $sandy->pc->solo->wins . ' solo games and ' . $sandy->pc->squad->wins . ' squad games!';

$auth = Auth::login('[email protected]','password');

// Get list of friends
// Params:
//  - boolean $ount Id of a user that you're going to add
$auth->profile->addFriend($accountId);

// Remove user from a friendlist
// Params:
// - string $accountId Account Id of a user that you're going to remove
// Returns int 204 on success
$successfullyRemoved = $auth->profile->removeFriend($accountId) === 204;



$auth = Auth::login('[email protected]','password');
var_dump($auth->leaderboard->get(Platform::PC, Mode::DUO)); 


$auth = Auth::login('[email protected]','password');
var_dump($auth->news->get(News::BATTLEROYALE, Language::ENGLISH)); 

$auth = Auth::login('[email protected]','password');
var_dump($auth->store->get(Language::ENGLISH)); 

$auth = Auth::login('[email protected]','password');
// All weekly challenges
var_dump($auth->profile->challenges->getWeeklys()); 

// Or just get a specific week (in this example, week 1)
var_dump($auth->profile->challenges->getWeekly(1));