문의 시, 사용하시는 개발환경과 디벨로퍼스 앱ID를 알려주세요.
___개발환경은 Java이며, 디벨로퍼스 앱ID는 woori입니다
public List<KaKaoMapResponse.Document> searchRestaurants(String query, double lat, double lng, int radius) {
String url = “https://dapi.kakao.com/v2/local/search/keyword.json”;
HttpHeaders headers = new HttpHeaders();
headers.set(“Authorization”, "KakaoAK " + RestKey);
HttpEntity entity = new HttpEntity<>(headers);
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("query", query)
.queryParam("x", lng)
.queryParam("y", lat)
.queryParam("radius", radius)
.queryParam("category_group_code", "FD6");
ResponseEntity<KaKaoMapResponse> response = restTemplate.exchange(
uriBuilder.toUriString(),
HttpMethod.GET,
entity,
KaKaoMapResponse.class
);
try {
String jsonResponse = objectMapper.writeValueAsString(response.getBody());
log.info("Response from Kakao API (JSON): {}", jsonResponse);
} catch (Exception e) {
log.error("Failed to convert response to JSON", e);
}
return Objects.requireNonNull(response.getBody()).getDocuments();
}
postman에서 http://localhost:8080/api/kakao-map/search?query=음식점&lat=37.5665&lng=126.9780&radius=2000 url로 테스트했는데 ""값이 나옵니다.