2014-05-31 14:39:35 +04:00
|
|
|
<?php
|
2015-11-05 14:20:11 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
class Rue89Bridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2018-11-08 01:13:45 +03:00
|
|
|
const MAINTAINER = 'teromene';
|
2017-02-11 18:16:56 +03:00
|
|
|
const NAME = 'Rue89';
|
2018-11-08 01:13:45 +03:00
|
|
|
const URI = 'https://www.nouvelobs.com/rue89/';
|
|
|
|
const DESCRIPTION = 'Returns the newest posts from Rue89';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$jsonArticles = getContents('https://appdata.nouvelobs.com/rue89/feed.json');
|
2018-11-08 01:13:45 +03:00
|
|
|
$articles = json_decode($jsonArticles)->items;
|
|
|
|
foreach ($articles as $article) {
|
|
|
|
$this->items[] = $this->getArticle($article);
|
2015-01-30 21:56:55 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
|
2018-11-08 01:16:28 +03:00
|
|
|
private function getArticle($articleInfo)
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$articleJson = getContents($articleInfo->json_url);
|
2018-11-08 01:16:28 +03:00
|
|
|
$article = json_decode($articleJson);
|
2018-11-08 01:13:45 +03:00
|
|
|
$item = [];
|
|
|
|
$item['title'] = $article->title;
|
|
|
|
$item['uri'] = $article->url;
|
|
|
|
if ($article->content_premium !== null) {
|
|
|
|
$item['content'] = $article->content_premium;
|
|
|
|
} else {
|
|
|
|
$item['content'] = $article->content;
|
|
|
|
}
|
|
|
|
$item['timestamp'] = $article->date_publi;
|
|
|
|
$item['author'] = $article->author->show_name;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
$item['enclosures'] = [];
|
|
|
|
foreach ($article->images as $image) {
|
|
|
|
$item['enclosures'][] = $image->url;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
$item['categories'] = [];
|
|
|
|
foreach ($article->categories as $category) {
|
|
|
|
$item['categories'][] = $category->title;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
return $item;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2014-05-31 14:39:35 +04:00
|
|
|
}
|