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
|
<?php
class WorldbankBridge extends BridgeAbstract
{
const NAME = 'World Bank Group';
const URI = 'https://www.worldbank.org/en/news/all';
const DESCRIPTION = 'Return articles from The World Bank Group All News';
const MAINTAINER = 'tillcash';
const PARAMETERS = [
[
'lang' => [
'name' => 'Language',
'type' => 'list',
'defaultValue' => 'English',
'values' => [
'English' => 'English',
'French' => 'French',
]
],
'limit' => [
'name' => 'limit (max 100)',
'type' => 'number',
'defaultValue' => 5,
'required' => true,
]
]
];
public function collectData()
{
$apiUrl = 'https://search.worldbank.org/api/v2/news?format=json&rows='
. min(100, $this->getInput('limit'))
. '&lang_exact=' . $this->getInput('lang');
$jsonData = json_decode(getContents($apiUrl));
// Remove unnecessary data from the original object
if (isset($jsonData->documents->facets)) {
unset($jsonData->documents->facets);
}
foreach ($jsonData->documents as $element) {
$this->items[] = [
'uid' => $element->id,
'timestamp' => $element->lnchdt,
'title' => $element->title->{'cdata!'},
'uri' => $element->url,
'content' => $element->descr->{'cdata!'},
];
}
}
}
|