-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkolisnet.php
106 lines (102 loc) · 2.71 KB
/
kolisnet.php
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
98
99
100
101
102
103
104
105
106
<?php
// -*- coding: utf-8 -*-
/* kolisnet.php
* search kolisnet & return ebook
* Input:
* type : [book|author]
* keyword: <string>
* page : <num>
*
* released under GPLv3
*/
/* KOLIS-NET API
* Query URL: http://nl.go.kr/kolisnet/openApi/open.php
* collection_set : 1(단행본)
* page : 1
* search_field1 : [total_field | title | author]
* value1 : 검색어
* per_page : 10
*
* Search Result: XML format
* METADATA::
* TOTAL::
* RECORD::
* NUMBER =
* TITLE = 제목
* AUTHOR = 저자
* PUBLISHER = 출판사
* PUBYEAR = 출판연도
* TYPE = [일반도서 | 컴퓨터파일 | 아동청소년컴퓨터파일]
* CONTENTS =
* LIB_NAME = 도서관명
* LIB_CODE = 도서관부호
* REC_KEY = 고유키
*
* Detail URL: http://nl.go.kr/kolisnet/openApi/open.php
* rec_key : 고유키
*
* Detail Result: XML format
* METADATA::
* BIBINFO::
* TITLE_INFO = 제목 / 저자
* SERIES_INFO =
* ISBN = ISBN코드
* HOLDINFO::
* NUMBER =
* LOCAL = 지역정보
* LIB_NAME = 도서관명
* LIB_CODE = 도서관부호
*/
$srchtype = $_GET['type'];
$keyword = $_GET['keyword'];
$page = (int)$_GET['page'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>국가자료공동목록 전자책 검색</title>
<link rel="stylesheet" type="text/css" href="search.css" />
</head>
<body>
<?php
$tblhdr = <<<EOD
<tr class="outhdr">
<th>제목</th>
<th>저자</th>
<th>출판사</th>
<th>출판년도</th>
<th>도서관</th>
</tr>
EOD;
echo "<table cellspacing=\"10\">".PHP_EOL;
$root_url = "http://nl.go.kr/kolisnet/openApi/open.php";
$fields = array(
'collection_set' => 1,
'page' => $page,
'search_field1' => $srchtype,
'value1' => $keyword,
'per_page' => 100
);
$url = $root_url."?".http_build_query($fields,"&");
$result = simplexml_load_file($url);
if ($result->TOTAL == '0') {
echo "<tr><td colspan=\"5\">검색된 목록이 없습니다</td></tr>".PHP_EOL;
} else {
echo $tblhdr.PHP_EOL;
foreach ($result->RECORD as $record) {
if ($record->TYPE != "컴퓨터파일")
continue;
echo " <tr>".PHP_EOL;
echo " <td class=\"title\">".$record->TITLE."</td>".PHP_EOL;
echo " <td>".$record->AUTHOR."</td>".PHP_EOL;
echo " <td>".$record->PUBLISHER."</td>".PHP_EOL;
echo " <td>".$record->PUBYEAR."</td>".PHP_EOL;
echo " <td>".$record->LIB_NAME."</td>".PHP_EOL;
echo " </tr>".PHP_EOL;
}
}
echo "</table>".PHP_EOL;
?>
</body>
</html>