mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 06:08:27 +01:00
feat: new bridge QnapBridge (#3020)
This commit is contained in:
parent
70ba6c5b53
commit
e63e3d072c
30
bridges/QnapBridge.php
Normal file
30
bridges/QnapBridge.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
final class QnapBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'QNAP';
|
||||
const URI = 'https://www.qnap.com/fr-fr/security-news/2022';
|
||||
const DESCRIPTION = 'Unofficial feed for security news';
|
||||
const MAINTAINER = 'dvikan';
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$thisYear = date('Y');
|
||||
$url = sprintf('https://www.qnap.com/api/v1/articles/security-news?locale=fr-fr&year=%s&page=1', $thisYear);
|
||||
$response = json_decode(getContents($url));
|
||||
foreach ($response->data as $post) {
|
||||
$item = [];
|
||||
$item['uri'] = sprintf('https://www.qnap.com%s', $post->url);
|
||||
$item['title'] = $post->title;
|
||||
$item['timestamp'] = \DateTime::createFromFormat('Y-m-d', $post->date)->format('U');
|
||||
$image = sprintf('<img src="https://www.qnap.com%s">', $post->image_url);
|
||||
$item['content'] = $image . '<br><br>' . $post->desc;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
usort($this->items, function ($a, $b) {
|
||||
return $a['timestamp'] < $b['timestamp'];
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user