-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApi.php
More file actions
97 lines (86 loc) · 2.44 KB
/
Api.php
File metadata and controls
97 lines (86 loc) · 2.44 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="./Api.css">
</head>
<body>
<?php
$type = $_GET['type'];
if($type=="내과") {
$type="D001";
}
else if($type=="외과") {
$type="D006";
}
else if($type=="치과") {
$type="D026";
}
else if($type=="정형외과") {
$type="D008";
}
else if($type=="신경과") {
$type="D003";
}
else if($type=="성형외과") {
$type="D010";
}
else if($type=="산부인과") {
$type="D011";
}
else if($type=="이비인후과") {
$type="D013";
}
else if($type=="안과") {
$type="D012";
}
else if($type=="피부과") {
$type="D005";
}
else if($type=="비뇨기과") {
$type="D014";
}
$key = "mL5xQ8wYroWD4EAKfbSfoa9coea5YnX0n8iCN9ph4PWpPTWzNWglQPiXYyAGW%2B9WqVy52swX0B7TlN8fqiXo8w%3D%3D";
$Q0 = urlencode($_GET['area1']);
$Q1 = urlencode($_GET['area2']);
$QD = urlencode($type);
$url = "http://apis.data.go.kr/B552657/HsptlAsembySearchService/getHsptlMdcncListInfoInqire?Q0=".$Q0."&Q1=".$Q1."&QD=".$QD."&numOfRows=20&serviceKey=".$key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
$response = curl_exec ($ch);
curl_close($ch);
$result = new SimpleXMLElement($response);
// print_r($result);
// echo $result->body->items->item[0]->dutyAddr;
$count = count($result->body->items->item)-1;
?>
<script>
show_map=function(x, y, name, addr, tel ) {
location.href="./map.php?x="+x+"&y="+y+"&name="+name+"&addr="+addr+"&tel="+tel;
}
</script>
<img width="150px" height="50px"src="./logo.png"></img>
<div class="hospital">
<table class="demo-table">
<tr>
<td>주소</td>
<td>이름</td>
<td>지도</td>
</tr>
<?php while($count>=0) {
?> <tr>
<td><?php echo $result->body->items->item[$count]->dutyAddr;?></td>
<td><?php echo $result->body->items->item[$count]->dutyName;?></td>
<td><button class="btn" onclick="show_map('<?php echo $result->body->items->item[$count]->wgs84Lon;?>', '<?php echo $result->body->items->item[$count]->wgs84Lat;?>','<?php echo $result->body->items->item[$count]->dutyName;?>','<?php echo $result->body->items->item[$count]->dutyAddr;?>','<?php echo $result->body->items->item[$count]->dutyTel1;?>')">상세지도</button></td>
</tr>
<?php
$count--;
}
?>
</table>
</div>
</body>
</html>