I'm having an issue retrieving certain information from RiotGames API. The code shown below is me retrieving the wins and losses for game types (if available).
<?php
// get that summoner's wins and losses for each game type
$result = file_get_contents('https://na.api.pvp.net/api/lol/na/v1.3/stats/by-summoner/' . $summoner->id . '/summary?api_key=' . $apiKey);
$stats = json_decode($result);
// var_dump($stats);
foreach($stats->playerStatSummaries as $statSummary){
// $statSummary->losses: sometimes losses isn't set
$losses = property_exists($statSummary, 'losses')? $statSummary->losses : '(not available)';
print '<p><b>' . $statSummary->playerStatSummaryType . '</b>: ' .
$statSummary->wins . ' wins, ' . $losses . ' losses</p>';
}
?>
It fetches the wins and losses of Riot's API and returns it. But if I try to grab something different such as totalAssists from their aggregatedStats and replace wins with totalAssists it will return false with this error
"type 8 -- Undefined property: stdClass::$totalAssists -- at line 35"
Why does this not work? (You can find all the information of RiotsAPI by clicking here and then clicking the second "GET" under "STATS-V1.3"
It might be possible that the total assists doesn't exist also.
You said if you "replace wins with totalAssists" that you get an error. You need to check to see if wins exists too.