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 ) )
您可以就阵列如何工作给我的任何其他建议和提示也将不胜感激。