rss-bridge/bridges/SummitsOnTheAirBridge.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.5 KiB
PHP
Raw Normal View History

2022-03-25 11:48:55 +03:00
<?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';
2022-03-25 11:48:55 +03:00
const PARAMETERS = [
'Count' => [
'c' => [
'name' => 'count',
'required' => true,
'defaultValue' => 10
]
]
2022-03-25 11:48:55 +03:00
];
2022-03-25 11:48:55 +03:00
public function collectData()
{
$header = ['Content-type:application/json'];
$opts = [CURLOPT_HTTPGET => 1];
$json = getContents($this->getURI() . $this->getInput('c'), $header, $opts);
2022-03-25 11:48:55 +03:00
$spots = json_decode($json, true);
2022-03-25 11:48:55 +03:00
foreach ($spots as $spot) {
$summit = $spot['associationCode'] . '/' . $spot['summitCode'];
2022-03-25 11:48:55 +03:00
$title = $spot['activatorCallsign'] . ' @ ' . $summit . ' ' .
$spot['frequency'] . ' MHz';
2022-03-25 11:48:55 +03:00
$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']}
2022-03-25 12:41:27 +03:00
EOL;
2022-03-25 11:48:55 +03:00
$this->items[] = [
'uri' => 'https://sotawatch.sota.org.uk/en/',
'title' => $title,
'content' => $content,
'timestamp' => $spot['timeStamp']
];
}
}
}