File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ function get_lat_long ($ address ) {
4
+ $ apiUrl = "https://address.dawul.co.kr/input_pro.php " ;
5
+ $ curl = curl_init ();
6
+
7
+ curl_setopt_array ($ curl , array (
8
+ CURLOPT_URL => $ apiUrl ,
9
+ CURLOPT_SSL_VERIFYPEER => 0 ,
10
+ CURLOPT_SSL_VERIFYHOST => 0 ,
11
+ CURLOPT_RETURNTRANSFER => 1 ,
12
+ CURLOPT_POST => 1 ,
13
+ CURLOPT_POSTFIELDS => 'refine_ty=8&protocol_= ' .urlencode ($ address ),
14
+ CURLOPT_HTTPHEADER => array (
15
+ 'Content-Type: application/x-www-form-urlencoded '
16
+ ),
17
+ ));
18
+
19
+
20
+ $ response = curl_exec ($ curl );
21
+ curl_close ($ curl );
22
+ $ temp = explode ("| " , $ response );
23
+ $ arr [0 ] = $ temp [4 ];
24
+ $ arr [1 ] = $ temp [3 ];
25
+
26
+ //서울특별시 중구 한강대로 405 (봉래동2가, 경부고속철도서울민자역사)|서울특별시 중구 봉래동2가 122-11 |04509|126.969422|37.5562730
27
+ /*
28
+ 서울특별시 중구 한강대로 405 (봉래동2가, 경부고속철도서울민자역사)
29
+ 서울특별시 중구 봉래동2가 122-11
30
+ 04509
31
+ 126.969422
32
+ 37.5562730
33
+ */
34
+
35
+ return $ arr ;
36
+ }
37
+
38
+ $ address = "서울 중구 한강대로 405 " ;
39
+ $ result = get_lat_long ($ address );
40
+ print ("주소: " .$ address ."\n\n" );
41
+ print ("위도: {$ result [0 ]}, 경도: {$ result [1 ]}" );
42
+ ?>
You can’t perform that action at this time.
0 commit comments