PHP code example of xgerhard / destiny-api-wrapper
1. Go to this page and download the library: Download xgerhard/destiny-api-wrapper 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/ */
xgerhard / destiny-api-wrapper example snippets
$oDestiny = new Destiny\Client('Bungie-API-key-here');
use Destiny\Client;
use Destiny\Exceptions\PlayerNotFoundException;
try
{
$oDestiny = new Destiny\Client('Bungie-API-key-here');
$oPlayer = $oDestiny->searchPlayer('xgerhard');
echo $oPlayer->membershipId; // 4611686018467322796
echo $oPlayer->membershipType; // 4
echo $oPlayer->displayName; // xgerhard#21555
// There are multiple ways of searching a player
// Search on all platforms by player username
$oPlayer = $oDestiny->searchPlayer('xgerhard');
// Search on specific platform by player username (1 = xbox, 2 = ps, 3 = pc)
$oPlayer = $oDestiny->searchPlayer('xgerhard', 1);
// Search by BungieNet uniqueName
// Set an unique ID here: https://www.bungie.net/en/Profile/Settings/?category=AboutMe
// Link the platforms you play on here: https://www.bungie.net/en/Profile/Settings/?category=Accounts
// By using profiles->getCurrent you will receive the platform you played on most recently
$oPlayer = $oDestiny->searchUser('xgerhard')->profiles->getCurrent();
// Combination of searchPlayer & searchUser
// Search by platform username first, if no results search by uniqueName on BungieNet
$oPlayer = $oDestiny->searchPlayerUser('xgerhard');
// Search on specific platform only, if no results search by uniqueName on BungieNet
$oPlayer = $oDestiny->searchPlayerUser('xgerhard', 1);
// $oPlayer = Destiny\Player
}
catch(PlayerNotFoundException $e)
{
// If no players could be found
echo $e->getMessage();
}
use Destiny\Client;
use Destiny\Exceptions\InvalidPlayerParametersException;
try
{
$oDestiny = new Destiny\Client('Bungie-API-key-here');
$oPlayer = $oDestiny->loadPlayer([
'membershipType' => 4,
'membershipId' => '4611686018467322796',
'displayName' => 'xgerhard#21555'
]);
// $oPlayer = Destiny\Player
}
catch(InvalidPlayerParametersException $e)
{
// If
$oPlayer = $oDestiny->searchPlayer('xgerhard');
// If I only need the characters data (for example: characterId, dateLastPlayed)
$aCharacters = $oPlayer->characters->fetch([200]);
// If I want to check characters inventory
$oPlayer->characters->fetch([
200, // Character basic info
205, // Character equipment
300, // Item instances
305 // Item sockets
]);
// Get primary weapon for all characters
foreach($oPlayer->characters->getAll() as $oCharacter)
{
$oPrimary = $oCharacter->inventory->get('primary');
}
// Or just for the current character
$oPlayer->characters->getCurrent()->inventory->get('primary');