-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwcsearchapi.php
More file actions
50 lines (37 loc) · 1 KB
/
Copy pathwcsearchapi.php
File metadata and controls
50 lines (37 loc) · 1 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
<?php
require_once('keys.inc');
$key = API_KEY;
$start = 0;
$count = 25;
//$format = "rss";
$cformat = "mla";
$query = "philosophy of education";
function pullXml($url) {
$xml = file_get_contents($url);
if (!$xml) {
throw new Exception("Unable to get results!");
} else {
return $xml;
}
}
//function worldcat_opensearch($key,$query,$format,$start,$count,$cformat) {
function worldcat_opensearch($key,$query,$start,$count,$cformat) {
// construct worldcat opensearch request
$url = "http://www.worldcat.org/webservices/catalog/search/worldcat/";
$url .= "opensearch?q=";
$url .= urlencode($query);
//$url .= "&format=".$format;
$url .= "&start=".$start;
$url .= "&count=".$count;
$url .= "&cformat=".$cformat;
$url .= "&wskey=".$key;
try {
return pullXml($url);
} catch (Exception $e) {
echo $e->getMessage();
}
}
//worldcat_opensearch($key,$query,$format,$start,$count,$cformat);
$results = worldcat_opensearch($key,$query,$start,$count,$cformat);
print_r($results);
?>