롤 소환사 조회 왜 안될까요??
본문
<?php
$text = $_GET['summoner_name'];
$summoner_name = urlencode($text);
$api_key="RGAPI-b5aa7dad-a063-4964-880c-1148f49b561d";
$url = "https://kr.api.riotgames.com/lol/summoner/v3/summoners/by-name/".$summoner_name."?api_key=".$api_key;
$is_post = false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($response, true);
$url = "https://kr.api.riotgames.com/lol/league/v3/positions/by-summoner/".$result[id]."?api_key=".$api_key;
$ch = curl_init();
$is_post = false;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$league = json_decode($response, true);
?>
<form action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>" method="get">
롤 소환사 조회 <input type="text" name="summoner_name" id="summoner_name" value="<?=$text?>"> <input type="submit" value="소환사 검색" class="btn_poll">
<p>소환사 이름: <?php echo $text;?></p>
<p>소환사 레벨: <?php echo $result[summonerLevel];?></p>
<p>승: <?php echo $league[0][wins];?> 패: <?php echo $league[0][losses];?></p>
<p>티어: <?php echo $league[0][tier]; echo " ".$league[0][rank];?></p>
<p>LP: <?php echo $league[0][leaguePoints];?></p>
</form>