api 고수님들 도와주세요
본문
워크넷API 채용정보를 구축중인데요
https://openapi.work.go.kr/opi/opi/opia/wantedApiDetailVw.do
위 부분을 적용하려는데
제 소스는
-----------------------------------------------------------------------------------------------
<!-- mainSection -->
<div style="font-size:17px">
<?
// 채용정보 url
$url = "http://openapi.work.go.kr/opi/opi/opia/wantedApi.do";
// 채용정보 각각의 요청변수들 - 광주광역시, 15개불러오기, 고령자
$var = "authKey=[인증키]&callTp=D&returnType=XML
&wantedAuthNo=[구인인증번호]&infoSvc=VALIDATION";
$data = file_get_contents($url . $var);
$xml = simplexml_load_string($data);
// 전체적인 내용 출력
echo "<pre>";
print_r($xml);
echo "</pre>";
?>
</div>
<!-- //mainSection -->
--------------------------------------------------------------------------------------
이렇게 하고 소스를 실행하면
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 102: parser error : StartTag: invalid element name in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: if (limSizeLst[1] < newFontSize) newFontSize = limSizeLst[1]; in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 103: parser error : StartTag: invalid element name in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: if (newFontSize < limSizeLst[0]) newFontSize = limSizeLst[0]; in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 311: parser error : EntityRef: expecting ';' in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: remote = window.open("https://www.eprivacy.or.kr:40018/seal/mark.jsp?mark=e&code in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 339: parser error : Entity 'copy' not defined in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: <p><img src="/images/common/layout/copyright.gif" alt="Copyright © 고용 in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /host/home2/kyungbiwon/html/sub_con/apii.php on line 29
Warning: Invalid argument supplied for foreach() in /host/home2/kyungbiwon/html/sub_con/apii.php on line 37
----------------------------------------------------------------------------------------------------
이렇게 에러가 발생합니다
고수님들 해결부탁드립니다
답변 4
오류문자 그대로 입니다.
simplexml_load_string()
특수문자 채크해보세요.
각각 출력해보세요
<?php
echo "url: [{$url}]<br />";
echo "var: [{$var}]<br />";
echo "urlvar: [{$url}{$var}]<br />";
$data = file_get_contents($url . $var);
echo 'data: ' . $data;
?>
혹시나 하는 질문인데
$var = "authKey=[인증키]&callTp=D&returnType=XML
&wantedAuthNo=[구인인증번호]&infoSvc=VALIDATION";
위의 [인증키] , [구인인증번호] 는 실제값을 넣고 작동시킨거죠?
$data = file_get_contents($url . $var);
echo $data;
// 하셔서 브라우저에서 소스 보기로 xml 데이터가 잘 나오는지 확인해 보세요.