-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpla.php
47 lines (40 loc) · 1023 Bytes
/
dpla.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
<?php
include_once 'api_key.php';
abstract class DplaBase {
public $api_key;
public $query;
/**
* @param $api_key
* @param $query
*/
public function __construct($api_key, $query) {
$this->api_key = $api_key;
$this->terms = $this->clean($query['q']);
$this->q = "http://api.dp.la/v2/items?q=" . $this->terms;
$this->decade = (isset($query['decade'])) ? $this->clean($query['decade']) : false;
}
/**
* @return mixed
*/
abstract public function curl_call();
/**
* @param $response
* @return mixed
*/
abstract public function process_json($response);
/**
* @param $response
* @return mixed
*/
protected function get_json($response) {
return json_decode($response, true);
}
/**
* @param $url
* @return string
*/
protected function clean($url) {
$clean = strip_tags(trim($url));
return preg_replace('/(\s{1,}|,)/', '+AND+', $clean);
}
}