PHP code example of richard4339 / destiny2-php

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

    

richard4339 / destiny2-php example snippets


composer 



$client = new \Destiny\Client('[YOUR API KEY]', '[OPTIONAL OAUTH TOKEN]', '[OPTIONAL CLIENT ID]', '[OPTIONAL CLIENT SECRET]', '[OPTIONAL YOUR APP NAME]', '[OPTIONAL YOUR APP VERSION]', '[OPTIONAL YOUR APP ID]', '[OPTIONAL YOUR APP URL]', '[OPTIONAL YOUR APP EMAIL]');
  
$clan = $client->getGroup(12345);
  
try {
    $whoami = $client->getBungieUser(9999999999);
} catch (\Destiny\Exceptions\ClientException $x) {
    
}
  
$members = $client->getClanAdminsAndFounder(12345);



namespace App\Services;


use Destiny\Client;
use Symfony\Component\Security\Core\Security;


/**
 * Class BungieOAuthRequest
 * @package App\Services
 */
class BungieOAuthRequest extends Client
{

    /**
     * BungieOAuthRequest constructor.
     * @param Security $security
     * @param string $apiKey
     * @param null|string $clientID
     * @param null|string $clientSecret
     * @param null|string $appName
     * @param null|string $appVersion
     * @param null|string $appIDNumber
     * @param null|string $appURL
     * @param null|string $appEmail
     * @throws \Destiny\Exceptions\ApiKeyException
     */
    public function __construct(Security $security, string $apiKey = '', ?string $clientID = null, ?string $clientSecret = null, ?string $appName = '', ?string $appVersion = '', ?string $appIDNumber = '', ?string $appURL = '', ?string $appEmail = '')
    {
        $user = $security->getUser();

        $token = $user->getBungieAccessToken();
        parent::__construct($apiKey, $token, $clientID, $clientSecret, $appName, $appVersion, $appIDNumber, $appURL, $appEmail);
    }
}