mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 16:17:28 +02:00
[WarhammerComBridge] Bridge for Warhammer Community blog (#4610)
* [WarhammerComBridge] Bridge for Warhammer Community blog * Fix Linter issues
This commit is contained in:
committed by
GitHub
parent
2ca696c1cf
commit
71808aaa81
51
bridges/WarhammerComBridge.php
Normal file
51
bridges/WarhammerComBridge.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class WarhammerComBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'Warhammer Community Blog';
|
||||
const URI = 'https://www.warhammer-community.com';
|
||||
const DESCRIPTION = 'Warhammer Community Blog';
|
||||
const MAINTAINER = 'thefranke';
|
||||
const CACHE_TIMEOUT = 86400;
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$url = static::URI . '/api/search/news/';
|
||||
|
||||
$header = [
|
||||
'Content-Type: application/json',
|
||||
];
|
||||
|
||||
$data = '{"sortBy":"date_desc","category":"","collections":["articles"],"game_systems":[],"index":"news","locale":"en-gb","page":0,"perPage":16,"topics":[]}';
|
||||
|
||||
$opts = [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_RETURNTRANSFER => true
|
||||
];
|
||||
|
||||
$json = getContents($url, $header, $opts);
|
||||
$json = json_decode($json);
|
||||
|
||||
foreach ($json->news as $article) {
|
||||
$articleurl = static::URI . $article->uri;
|
||||
|
||||
$fullarticle = getSimpleHTMLDOMCached($articleurl);
|
||||
$content = $fullarticle->find('.article-content', 0);
|
||||
|
||||
$categories = [];
|
||||
foreach ($article->topics as $topic) {
|
||||
$categories[] = $topic->title;
|
||||
}
|
||||
|
||||
$this->items[] = [
|
||||
'title' => $article->title,
|
||||
'uri' => static::URI . $article->uri,
|
||||
'timestamp' => strtotime($article->date),
|
||||
'content' => $content,
|
||||
'uid' => $article->uuid,
|
||||
'categories' => $categories
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user