1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
    header("Content-Type: text/html; charset=UTF-8");
    //get the default response headers 
    header("Access-Control-Allow-Origin: *");
 
    $apikey = "B3cwQGSaQMxbw6bP6GTmp%2B66H85SvE%2FlBf4Kf5PC2%2B7AEpOCLZY02sacI4C0xBEezV0v2uICHQMq%2Bk8aNnSM1w%3D%3D";
 
    $url = "http://apis.data.go.kr/B553077/api/open/sdsc/storeZoneInAdmi?divId=ctprvnCd&key=$code&ServiceKey=$apikey&type=json";
    
    $ch = curl_init();
 
    // curl 옵션 설정
    curl_setopt($ch, CURLOPT_URL, $url);                // url 주소
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        // 리턴 결과값을 문자열로 반환
    curl_setopt($ch, CURLOPT_HEADER, false);            // 헤더값 가져오는 여부
    
    //Execute request 
    $response = curl_exec($ch);
    
    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
    if($status_code == 200) {
        echo $response;
    } else {
        echo "Error 내용:".$response;
    }
 
    //close connection 
    curl_close($ch);
    flush();
?>
 

+ Recent posts