Sample Code
Closed this issue · 3 comments
ProjectCleverWeb commented
Is there any chance you could provide some sample code for using this library?
ProjectCleverWeb commented
It took some time, but I was able to discern the code well enough to get myself started. Here is what I have so far:
<?php
require_once __DIR__.'/vendor/autoload.php';
use GuzzleHttp\Client as GuzzleClient;
$guzzle_client = new GuzzleClient(['verify' => FALSE]);
$client = new AdamDBurton\Destiny2ApiClient\Api('REDACTED', $guzzle_client);
$result = $client->destiny2->searchDestinyPlayer(2, 'WIN__MAN')->getData();
$player = $result[0];
$player->iconPath; // PSN Icon
$player->membershipType; // Membership Type
$player->membershipId; // Account ID
$player->displayName; // Display Name
$result = (array) $client->destiny2->getProfile(2, $player->membershipId, 200)->getData()->characters->data;
$characters = $result;
$p_char = $characters['2305843009262152964'];
$result = $client->destiny2->getHistoricalStats(2, $player->membershipId, $p_char->characterId)->getData();
print_r($result);
adamdburton commented
I've added a README.md file with example usage.
P.S. You don't have to pass a Guzzle instance through as a second parameter, one is created inside the class.
ProjectCleverWeb commented
Thank you!
Also, due to my local environment I need to turn off SSL verification. Which is why I am making my own guzzle instance.