0

enter code hereこのコードが返すエラーは

「オブジェクト以外のプロパティを取得しようとしています」または「メッセージ: 未定義のプロパティ: stdClass::$name」。

変数$summonerは機能しません。変数 sID、$lcaseregion、$APIkey (など) がすべて適切に設定されていると仮定します。

    <?php
    $summonerURL = "https://$lcaseRegion.api.pvp.net/api/lol/$lcaseRegion/v1.4/summoner/" . $sID . "?api_key=9" . $APIkey;
    $responseSummoner = @file_get_contents($summonerURL);
    $summoner = @json_decode($responseSummoner);
    echo print_r($summoner); //this works and prints things
    echo $summoner->name; //this does not work
    echo $summoner->profileIconId; //this also does not work.
    //please find print_r results below...
    ?>

print_r 結果;

stdClass Object ( [41245441] => stdClass Object ( [id] => 41245441 [name] => Bubbalubagus [profileIconId] => 558 [revisionDate] => 1488775287000 [summonerLevel] => 30 ) )

配列がどのように機能するかについて、他のアドバイスやヒントをいただければ幸いです。

4

1 に答える 1