테스트 사이트 - 개발 중인 베타 버전입니다

롤 소환사 조회 왜 안될까요?? 채택완료

위치앱 3년 전 조회 2,234

<?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>

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

에러 안나와요?

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

위치앱
3년 전
에러는 안나오고 그냥 소환사 id가 없다고만 나오네요
투엑스비
3년 전
아~ 그러면 아이디를 디버깅 함수로 해보세요 print_r2로 해보세요

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인