2014-05-31 14:39:35 +04:00
|
|
|
<?php
|
2018-11-08 01:13:45 +03:00
|
|
|
class Rue89Bridge extends BridgeAbstract {
|
2015-11-05 14:20:11 +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';
|
2015-11-05 14:20:11 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
public function collectData() {
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2018-11-08 01:13:45 +03:00
|
|
|
$jsonArticles = getContents('https://appdata.nouvelobs.com/rue89/feed.json')
|
2019-06-07 21:38:07 +03:00
|
|
|
or returnServerError('Unable to query Rue89 !');
|
2018-11-08 01:13:45 +03:00
|
|
|
$articles = json_decode($jsonArticles)->items;
|
|
|
|
foreach($articles as $article) {
|
|
|
|
$this->items[] = $this->getArticle($article);
|
|
|
|
}
|
2016-06-22 00:33:51 +03:00
|
|
|
|
2015-01-30 21:56:55 +03:00
|
|
|
}
|
|
|
|
|
2018-11-08 01:16:28 +03:00
|
|
|
private function getArticle($articleInfo) {
|
2018-11-08 01:13:45 +03:00
|
|
|
|
2019-06-07 21:38:07 +03:00
|
|
|
$articleJson = getContents($articleInfo->json_url)
|
|
|
|
or returnServerError('Unable to get article !');
|
2018-11-08 01:16:28 +03:00
|
|
|
$article = json_decode($articleJson);
|
2018-11-08 01:13:45 +03:00
|
|
|
$item = array();
|
|
|
|
$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;
|
|
|
|
|
|
|
|
$item['enclosures'] = array();
|
|
|
|
foreach($article->images as $image) {
|
|
|
|
$item['enclosures'][] = $image->url;
|
|
|
|
}
|
|
|
|
|
|
|
|
$item['categories'] = array();
|
|
|
|
foreach($article->categories as $category) {
|
|
|
|
$item['categories'][] = $category->title;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $item;
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2014-05-31 14:39:35 +04:00
|
|
|
}
|