|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Services\FeUser; |
|
3
|
|
|
|
|
4
|
|
|
use \Httpful\Request; |
|
5
|
|
|
|
|
6
|
|
|
class GndDataService |
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
protected $apiUrl = 'http://lobid.org/gnd/'; |
|
10
|
|
|
|
|
11
|
|
|
public function __construct() { |
|
12
|
|
|
|
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
public function searchTermReplacement($searchTerm) { |
|
16
|
|
|
$searchTerm = str_replace('ä', 'ae', $searchTerm); |
|
17
|
|
|
$searchTerm = str_replace('Ä', 'Ae', $searchTerm); |
|
18
|
|
|
$searchTerm = str_replace('ö', 'oe', $searchTerm); |
|
19
|
|
|
$searchTerm = str_replace('Ö', 'Oe', $searchTerm); |
|
20
|
|
|
$searchTerm = str_replace('ü', 'ue', $searchTerm); |
|
21
|
|
|
$searchTerm = str_replace('Ü', 'Ue', $searchTerm); |
|
22
|
|
|
return str_replace(' ', '+', $searchTerm); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function searchPersonRequest($searchTerm) { |
|
26
|
|
|
$response = Request::get($this->apiUrl . 'search?filter=type:Person&format=json&q=' . $this->searchTermReplacement($searchTerm)) |
|
27
|
|
|
->send(); |
|
28
|
|
|
|
|
29
|
|
|
return ['entries' => $response->body->member]; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getPersonData($gndId) { |
|
33
|
|
|
$response = Request::get($this->apiUrl . $gndId . '.json') |
|
34
|
|
|
->send(); |
|
35
|
|
|
|
|
36
|
|
|
return $response->body; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function searchOrganisationRequest($searchTerm) { |
|
40
|
|
|
$response = Request::get($this->apiUrl . 'search?filter=type:CorporateBody&format=json&q=' . $this->searchTermReplacement($searchTerm)) |
|
41
|
|
|
->send(); |
|
42
|
|
|
|
|
43
|
|
|
return ['entries' => $response->body->member]; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getOrganisationData($gndId) { |
|
47
|
|
|
$response = Request::get($this->apiUrl . $gndId . '.json') |
|
48
|
|
|
->send(); |
|
49
|
|
|
|
|
50
|
|
|
return $response->body; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |