[php] 자사주시세정보 API 서비스 예제
페이지 정보
본문
<?php
//1. 아래 code= 부분에 종목코드를 넣어주세요.
$url = "https://asp.koscom.co.kr/listservice/getStockInfoXML?code=005930&auth_key=Y0va9PYmoKiqWJ7oSVFiyIy2aVHq7lXj&gubun=K";
$data = preg_replace("/\n+/", "", file_get_contents($url));
$xml = simplexml_load_string($data);
$NowTime = date("Y-m-d H:i:s",time());
$value_disInfo = Count($xml->disInfo);
for($i=0;$i<$value_disInfo;$i++) {
$disInfo[$i][0] = $xml->disInfo[$i]['distime'];
$disInfo[$i][1] = $xml->disInfo[$i]['disAcpt_no'];
$disInfo[$i][2] = $xml->disInfo[$i]['disTitle'];
$disInfo[$i][3] = $xml->disInfo[$i]['submitOblgNm'];
}
?>
<span class="date_time"><span class="time_img"></span><?php echo $NowTime?> 기준</span>
<table id="disInfo">
<colgroup>
<col style="width:15%;"/>
<col style="width:15%;"/>
<col />
<col style="width:15%;" />
</colgroup>
<tr>
<th>번호</th>
<th>일자</th>
<th>공시제목</th>
<th>제출의무자</th>
</tr>
<?php if($value_disInfo > 0){ ?>
<?php for($k=0; $k<$value_disInfo;$k++) {?>
<tr>
<td><?php echo $value_disInfo-$k?></td>
<td><?php echo substr($disInfo[$k][0],0,4);?>/<?php echo substr($disInfo[$k][0],4,2);?>/<?php echo substr($disInfo[$k][0],6,2);?></td>
<td><a href="#" onclick="window.open('http://kind.krx.co.kr/common/disclsviewer.do?method=search&acptno=<?php echo $disInfo[$k][1]?>','공시상세보기','width=1200,height=800,top=100,left=350,toolbar=no,menubar=no,scrollbars=no,resizable=yes');return false;"><?php echo $disInfo[$k][2]?></a></td>
<td><?php echo $disInfo[$k][3]?></td>
</tr>
<?php } ?>
<?php } else {?>
<tr>
<td colspan="4">데이터가 없습니다.</td>
</tr>
<?php } ?>
</table>
관련링크
댓글목록
등록된 댓글이 없습니다.