2016-04-05 13 views
-1

私は、このコードは、APIにアクセスし、データを取得し、私のサイトに出力しますが、私は配列などに問題があります。必要なデータにアクセスできますか?非オブジェクトPHPのプロパティを取得しようとしていません

私の問題はである:

foreach($entrieszz as $statSummaryzz) 
{ $gamemodematchhistoryfellowPlayerslolsearch = $statSummaryzz->fellowPlayers->teamId; } 

とそのは私にエラーを与える: Trying to get games->fellowPlayers->teamId and also games->fellowPlayers->championId

これは何を次のとおりです。

アクセスしようとしたデータイムは、非オブジェクトのプロパティを取得しようとすると、私は持っています:

<?php 

$apiKey = 'e9044828-20e3-46cc-9eb5-545949299803'; 
$summonerName = 'tamini'; 
$new = rawurlencode($summonerName); 

$news = str_replace(' ', '', $summonerName); 
$str = strtolower($news); 

// get the basic summoner info 
$result = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/' . $new . '?api_key=' . $apiKey); 
$summoner = json_decode($result)->$str; 
$id = $summoner->id; 

// var_dump($summoner); 
?> 


<?php 


$clawzzeyu = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.3/game/by-summoner/' . $id . '/recent?api_key=' . $apiKey); 
$gazazzeyu = json_decode($clawzzeyu); 

$entrieszz = $gazazzeyu->games; 
usort($entrieszz, function($accc,$bccc){ 
    return $bccc->createDate-$accc->createDate; 
}); 


foreach($entrieszz as $statSummaryzz){ 
    $gamemodematchhistoryfellowPlayerslolsearch = $statSummaryzz->fellowPlayers->teamId; 
} 

?> 
+1

を必要とされるだろうか?それをもっとはっきりと説明してください - どの列に問題があり、どんなエラーが出ていますか? –

+0

私の問題はこの部分にあります。foreach($ entrieszz as $ statSummaryzz){ $ gamemodematchhistoryfellowPlayerslolsearch = $ statSummaryzz-> fellowPlayers-> teamId; }と私のエラーを与える:非オブジェクトのプロパティを取得しようとしています –

+0

ありがとう、質問としてではなく、コメントとして本体に追加してください - あなたの質問は閉じないでください –

答えて

0

json s十分な問題である正確に何があっteamIdはありませんが、唯一のチーム

foreach($entrieszz as $statSummaryzz){ 
$gamemodematchhistoryfellowPlayerslolsearch = $statSummaryzz->fellowPlayers->team; 
} 
+0

その部分は大丈夫、問題は$ gamemodematchhistoryfellowPlayerslolsearch = $ statSummaryzz-> fellowPlayers-> teamIdです。 –

+0

私はupdatebthe答えを持っている.. – scaisEdge

関連する問題