-
Notifications
You must be signed in to change notification settings - Fork 12
/
oai2client.php
85 lines (71 loc) · 3.33 KB
/
oai2client.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
<?php
/**
* https://www.openarchives.org/OAI/2.0/guidelines-harvester.htm
* 8. Harvesting all the Metadata from a Repository
*
* Proxies, aggregators and other such agents may wish to harvest a complete copy of a repository
* including set structure and all metadata formats. One strategy for doing this would be:
*
* # Issue an Identify request to find the finest datestamp granularity supported.
* # Issue a ListMetadataFormats request to obtain a list of all metadataPrefixes supported.
* # Harvest using ListRecords requests for each metadataPrefix supported. Knowledge of the
* datestamp granularity allows for less overlap if granularities finer than a day are supported.
* # Set structure can be inferred from the setSpec elements in the header blocks of each record
* returned (consistency checks are possible).
* # Items may be reconstructed from the constituent records. Local datestamps must be assigned to
* harvested items.
* # Provenance and other information in <about> blocks may be re-assembled at the item level if it
* is the same for all metadata formats harvested. However, this information may be supplied
* differently for different metadata formats and may thus need to be store separately for each
* metadata format.
*/
class OAI2Client {
public function __construct($server_base_url) {
$this->server_base_url = $server_base_url;
require_once('./curl.php');
$this->curl = new Curl();
}
public function Identify() {
return $this->curl->get($this->server_base_url.'?verb=Identify');
}
public function ListMetadataFormats($identifier = '') {
$url = $this->server_base_url.'?verb=ListMetadataFormats';
if (!empty($identifier)) {
$url .= "&identifier={$identifier}";
}
return $this->curl->get($url);
}
public function ListSets($resumptionToken = '') {
$url = $this->server_base_url.'?verb=ListSets';
return $this->curl->get($url);
}
public function ListIdentifiers($options = array()) {
$options_default = array('from' => null,
'until' => null,
'set' => null,
'resumptionToken' => null,
'metadataPrefix' => null); // required
$url = $this->server_base_url.'?verb=ListIdentifiers';
if (!empty($options['metadataPrefix'])) {
$url .= "&metadataPrefix={$options['metadataPrefix']}";
}
return $this->curl->get($url);
}
public function ListRecords($options = array()) {
$options_default = array('from' => null,
'until' => null,
'set' => null,
'resumptionToken' => null,
'metadataPrefix' => null); // required
$url = $this->server_base_url.'?verb=ListRecords';
if (!empty($options['metadataPrefix'])) {
$url .= "&metadataPrefix={$options['metadataPrefix']}";
}
return $this->curl->get($url);
}
public function GetRecord($identifier, $metadataPrefix) {
$url = $this->server_base_url.'?verb=ListRecords';
$url .= "&identifier={$identifier}&metadataPrefix={$metadataPrefix}";
return $this->curl->get($url);
}
}