왜 실행이 안되는지 궁금합니다. 채택완료

NHN 오픈 API 를 활용한 매시업 이라는 책을 보고 그대로 입력했는데 책에서는 실행된다고 하는데 저는 실행이 안되네요. 뭐가 잘못된건지 모르겠습니다. 책에는 api key 입력란이라고 되어 있는데 네이버에는 api key 만 따로 있는게 아니고 Client ID 와 Client Secret 이 있어서 client secret 만 입력했습니다.

​왜 작동을 안하는지 궁금하네요. 코드가 잘못된게 있나요?


링크는 여기 올렸습니다. :     http://awamp.duckdns.org/nhnbook.php

Copy
<?php define('NAVERKEY', '');  // 여기는 client ID 와 client secret 중에서 client ID 입력했음.	function callOpenApi($query, $target, $display, $start){		$encodequery = urlencode($query);		$url = "http://openapi.naver.com/search?query=$encodequery&target=" . $target ."&display=" . $display ."&start=" . $start ."&key=" . NAVERKEY;		$channel = simplexml_load_file($url)->channel;		return $channel;	}	$query = "";	$items = array();	if(isset($_GET["query"])){		$query = $_GET["query"];		$channel = callOpenApi($query, 'book', 10, 1);		$items = $channel->item;	} ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko"> <head> 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 	<title>네이버 책 검색</title> </head> <body> 	<!--검색 조건 입력폼--> 	<form name="form" method="get" action="<?php echo$_SERVER['PHP_SELF']?>"> 	<input type="text" name="query" value="<?php echo $query?>"> 	<input type="submit" value="책검색"> 	</form> 	<!--검색결과--> 	<ul> 	<?php 	foreach ($items as $item) { 		?>  	<li> 	<a href="<?php echo$item->link; ?>"> <?php echo$item->title;?></a> 	</li> 	<?php } ?> </ul> </body> </html>

답변 1개

채택된 답변
+20 포인트

우선 호출 uri 가 바뀐건지

http://openapi.naver.com/search?query=test

를 호출했을 때

{"errorMessage":"/search?query=test : API does not exist.","errorCode": "051"}

와 같은 메세지가 나오네요.


https://developers.naver.com/docs/search/blog/ 에서 확인사항 점검하셔야 할듯 합니다.

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

답변에 대한 댓글 1개

감사합니다. 함 해보겠습니다

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

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

로그인
🐛 버그신고