본문 바로가기
카카오 REST API & SDK/카카오 로컬

[REST API - PHP] 카카오 로컬(주소검색) - v20201218

by kakao-TAM 2020. 12. 9.
2020-12-18 Kakao API, PHP Simple Pack으로 예제 적옹
2020-12-09 최초등록

[Sample]

test-tam.pe.kr/kakao_local.php

 

카카오톡 로컬

GET dapi.kakao.com/v2/local/geo/coord2regioncode.json HTTP/1.1 Authorization: KakaoAK {REST_API_KEY} {"meta":{"total_count":2},"documents":[{"region_type":"B","code":"4113510900","address_name":"경기도 성남시 분당구 삼평동","region_1depth_name"

test-tam.pe.kr

 

[Code]

github.com/kakao-tam/MapAndLocal/blob/main/kakao_local.php

 

kakao-tam/MapAndLocal

MapAndLocal. Contribute to kakao-tam/MapAndLocal development by creating an account on GitHub.

github.com

 

[Reference]

[Infomation]

* Curl

  •  주의 : query 파라메터의 data는 urlencode로 감싸서 호출 할 것.
curl -v -X GET "https://dapi.kakao.com/v2/local/search/address.json" \ --data-urlencode "query=전북 삼성동 100" \ -H "Authorization: KakaoAK REST_API_KEY"

* Response Json Example

  • 주의 : Return 값에 road_address가 없는 경우도 있음.
{"documents":[
	{"address":{"address_name":"전북 익산시 부송동 100",
    			"b_code":"4514013400","h_code":"4514069000","main_address_no":"100",
                "mountain_yn":"N","region_1depth_name":"전북","region_2depth_name":"익산시",
                "region_3depth_h_name":"삼성동","region_3depth_name":"부송동",
                "sub_address_no":"","x":"126.99597495347","y":"35.9766482774579"},
     "address_name":"전북 익산시 부송동 100","address_type":"REGION_ADDR",
     "road_address":{"address_name":"전북 익산시 망산길 11-17","building_name":"",
     				"main_building_no":"11","region_1depth_name":"전북",
                    "region_2depth_name":"익산시","region_3depth_name":"부송동",
                    "road_name":"망산길","sub_building_no":"17","underground_yn":"N",
                    "x":"126.995995793098","y":"35.97675110933","zone_no":"54547"},
      "x":"126.99597495347","y":"35.9766482774579"},
      
      {"address":{"address_name":"전북 익산시 임상동 100","b_code":"4514013200","h_code":"4514069000","main_address_no":"100","mountain_yn":"N","region_1depth_name":"전북","region_2depth_name":"익산시","region_3depth_h_name":"삼성동","region_3depth_name":"임상동","sub_address_no":"","x":"126.980268573424","y":"35.9816612949055"},"address_name":"전북 익산시 임상동 100","address_type":"REGION_ADDR","road_address":null,"x":"126.980268573424","y":"35.9816612949055"},
      {"address":{"address_name":"전북 익산시 정족동 100","b_code":"4514013100","h_code":"4514069000","main_address_no":"100","mountain_yn":"N","region_1depth_name":"전북","region_2depth_name":"익산시","region_3depth_h_name":"삼성동","region_3depth_name":"정족동","sub_address_no":"","x":"127.002020445866","y":"35.9829740190924"},"address_name":"전북 익산시 정족동 100","address_type":"REGION_ADDR","road_address":null,"x":"127.002020445866","y":"35.9829740190924"}],
      
      "meta":{"is_end":true,"pageable_count":3,"total_count":3}}

 

  • category_group_code
Name Description
MT1 대형마트
CS2 편의점
PS3 어린이집, 유치원
SC4 학교
AC5 학원
PK6 주차장
OL7 주유소, 충전소
SW8 지하철역
BK9 은행
CT1 문화시설
AG2 중개업소
PO3 공공기관
AT4 관광명소
AD5 숙박
FD6 음식점
CE7 카페
HP8 병원
PM9 약국

 

[Error Case]

  •  has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.

확인 사항 1. ad blocker 같은 광고 차단 플러그인이 브라우저에 깔려있는지 확인

확인 사항 2. 도메인 추가 : 내 어플리케이션 > 앱 > 플랫폼 > web 플랫폼 > 사이트 도메인

확인 사항 3. 캐시 삭제

- Vue로 로컬에서 keywordSearch 함수 호출하는데 CORS 오류가 발생합니다

 

 

댓글0