이 API에서 데이터를 얻을 수 있지만이 문제가 방법 :내가 API에서 데이터를 얻을 원하는
foreach ($userdata as $Summoner)
{
$response = Unirest::get("https://community-league-of-legends.p.mashape.com/api/v1.0/$region/summoner/retrieveInProgressSpectatorGameInfo/" .
$Summoner['NICK'], array("X-Mashape-Authorization" =>
"$key"), null);
$array = ($response->raw_body);
$new = json_decode($array, true);
}
위해서 var_dump (새 $)를;
array(5) { ["playerCredentials"]=> array(11) { ["observerEncryptionKey"]=> string(32) "nZvmi1uhrXGW4hn1bD9u9eadte7x9dGK" ["dataVersion"]=> int(0) ["playerId"]=> int(28980822) ["serverPort"]=> int(0) ["observer"]=> bool(true) ["summonerId"]=> int(0) ["championId"]=> int(0) ["observerServerIp"]=> string(12) "95.172.65.26" ["gameId"]=> int(859406155) ["observerServerPort"]=> int(8088) ["lastSelectedSkinIndex"]=> int(0) } ["dataVersion"]=> int(0) ["gameName"]=> string(15) "match-859406155" ["reconnectDelay"]=> int(0) ["game"]=> array(33) { ["practiceGameRewardsDisabledReasons"]=> array(1) { ["array"]=> array(0) { } } ["glmSecurePort"]=> int(0) ["queuePosition"]=> int(0) ["playerChampionSelections"]=> array(1) { ["array"]=> array(10) .............
그러나 때 새로운 루프 $
foreach ($new as $usrGmID) {
}
나는이 얻을 : 위해서 var_dump ($ usrGmID를);
array(33) { ["practiceGameRewardsDisabledReasons"]=> array(1) { ["array"]=> array(0) { } } ["glmSecurePort"]=> int(0) ["queuePosition"]=> int(0) ["playerChampionSelections"]=> array(1) { ["array"]=> array(10) { [0]=> array(6) { ["spell1Id"]=> int(14) ["spell2Id"]=> int(4) ["championId"]=> int(238) ["summonerInternalName"]=> string(4) "nali" ["selectedSkinIndex"]=> int(0) ["dataVersion"]=> int(0) } [1]=> array(6) { ["spell1Id"]=> int(4) ["spell2Id"]=> int(3) ["championId"]=> int(99) ["summonerInternalName"]=> string(9) "gamepl121"..........
내가 얻지 못할 모든 데이터가 사라집니다.
제 궁금한 점은 [ "playerId"]와 [ "gameId"]를 얻고 이것을 새로운 배열로 밀어 넣을 수 있다는 것입니다.
나는 내가 이런 식으로 시도 :
$i = 0;
foreach ($userdata as $Summoner)
{
$response = Unirest::get("https://community-league-of-legends.p.mashape.com/api/v1.0/$region/summoner/retrieveInProgressSpectatorGameInfo/" .
$Summoner['NICK'], array("X-Mashape-Authorization" =>
"$key"), null);
$array = ($response->raw_body);
$new[$i] = json_decode($array, true);
$i = $i + 1;
}
foreach ($new as $usrGmID)
{
array_push($sumgameid, array("playerId" => $usrGmID["playerCredentials"]["playerId"],
"gameId" => $usrGmID["playerCredentials"]["gameId"]));
}
을하지만이 아래의 모든 내 코드 라인을 파괴.
다른 방법이 있습니까?
당신은 아마이 내 키없는 특정 값 귀하의 배열 ('observerEncryptionKey') ... – didierc
를 공유하고 싶지 않은 유일한 예 : P – user3705982