aboutsummaryrefslogtreecommitdiff
path: root/bridges/SummitsOnTheAirBridge.php
blob: 17431214c1469d9bd3900fe5900c8ebd16e41490 (plain) (blame)
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
<?php

class SummitsOnTheAirBridge extends BridgeAbstract
{
    const MAINTAINER = 's0lesurviv0r';
    const NAME = 'Summits On The Air Spots';
    const URI = 'https://api2.sota.org.uk/api/spots/';
    const CACHE_TIMEOUT = 60; // 1m
    const DESCRIPTION = 'Summits On The Air Activator Spots';

    const PARAMETERS = [
        'Count' => [
            'c' => [
                'name' => 'count',
                'required' => true,
                'defaultValue' => 10
            ]
        ]
    ];

    public function collectData()
    {
        $header = [
            'Content-type:application/json',
        ];
        $opts = [
            CURLOPT_HTTPGET => 1,
        ];
        $json = getContents($this->getURI() . $this->getInput('c'), $header, $opts);

        $spots = json_decode($json, true);

        foreach ($spots as $spot) {
            $summit = $spot['associationCode'] . '/' . $spot['summitCode'];

            $title = $spot['activatorCallsign'] . ' @ ' . $summit . ' ' .
                $spot['frequency'] . ' MHz';

            $content = <<<EOL
			<a href="http://summits.sota.org.uk/summit/{$summit}">
			{$summit}, {$spot['summitDetails']}</a><br />
			Frequency: {$spot['frequency']} MHz<br />
			Mode: {$spot['mode']}<br />
			Comments: {$spot['comments']}
EOL;

            $this->items[] = [
                'uri' => 'https://sotawatch.sota.org.uk/en/',
                'title' => $title,
                'content' => $content,
                'timestamp' => $spot['timeStamp']
            ];
        }
    }
}