PHP code example of tustin / cod-php

1. Go to this page and download the library: Download tustin/cod-php 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/ */

    

tustin / cod-php example snippets


use CallOfDuty\Client;

$client = new Client();
// Use Activision email and password to login.
$client->login('[email protected]', 'pa55w0rd');

// Username and platform the user plays on.
$user = $client->user('tustin25', 'psn');

$bo4 = $user->blackOps4();
// Or alternatively
$bo4 = $user->bo4(); // Alias of blackOps4()

$zm = $bo4->zombies();

// Spit out some user information
echo sprintf("Prestige %d, level %d\n", $zm->prestige(), $zm->level());
echo sprintf("\tKills - %d\n", $zm->lifetime()->kills());
echo sprintf("\tDowns - %d\n", $zm->lifetime()->downs());
echo sprintf("\tHeadshots - %d\n", $zm->lifetime()->headshots());


CallOfDuty\Client;

$client = new Client();
$client->login('[email protected]', 'pa55w0rd');

$zm = $client->user('tustin25', 'psn')->blackOps4()->zombies();

foreach ($zm->recentMatches() as $match) {
    echo sprintf(
        "%s - Round %d (%s)\n", 
        $match->map(),
        $match->roundReached(),
        $match->difficulty()
    );

    $stats = $match->playerStats();

    echo sprintf("\tKills - %d\n", $stats->kills());
    echo sprintf("\tDowns - %d\n", $stats->downs());
    echo sprintf("\tSpecialist Kills - %s\n", $stats->maxedSpecialWeaponKills());
}

echo sprintf("%s - Prestige %d, level %d\n", 'tustin25', $zm->prestige(), $zm->level());
echo sprintf("\tKills - %d\n", $zm->lifetime()->kills());
echo sprintf("\tDowns - %d\n", $zm->lifetime()->downs());
echo sprintf("\tHeadshots - %d\n", $zm->lifetime()->headshots());