2014-05-31 12:39:35 +02:00
|
|
|
<?php
|
2018-11-07 23:13:45 +01:00
|
|
|
class Rue89Bridge extends BridgeAbstract {
|
2015-11-05 12:20:11 +01:00
|
|
|
|
2018-11-07 23:13:45 +01:00
|
|
|
const MAINTAINER = 'teromene';
|
2017-02-11 16:16:56 +01:00
|
|
|
const NAME = 'Rue89';
|
2018-11-07 23:13:45 +01:00
|
|
|
const URI = 'https://www.nouvelobs.com/rue89/';
|
|
|
|
const DESCRIPTION = 'Returns the newest posts from Rue89';
|
2015-11-05 12:20:11 +01:00
|
|
|
|
2018-11-07 23:13:45 +01:00
|
|
|
public function collectData() {
|
2017-02-11 16:16:56 +01:00
|
|
|
|
2018-11-07 23:13:45 +01:00
|
|
|
$jsonArticles = getContents('https://appdata.nouvelobs.com/rue89/feed.json')
|
2019-06-07 20:38:07 +02:00
|
|
|
or returnServerError('Unable to query Rue89 !');
|
2018-11-07 23:13:45 +01:00
|
|
|
$articles = json_decode($jsonArticles)->items;
|
|
|
|
foreach($articles as $article) {
|
|
|
|
$this->items[] = $this->getArticle($article);
|
|
|
|
}
|
2016-06-21 23:33:51 +02:00
|
|
|
|
2015-01-30 19:56:55 +01:00
|
|
|
}
|
|
|
|
|
2018-11-07 23:16:28 +01:00
|
|
|
private function getArticle($articleInfo) {
|
2018-11-07 23:13:45 +01:00
|
|
|
|
2019-06-07 20:38:07 +02:00
|
|
|
$articleJson = getContents($articleInfo->json_url)
|
|
|
|
or returnServerError('Unable to get article !');
|
2018-11-07 23:16:28 +01:00
|
|
|
$article = json_decode($articleJson);
|
2018-11-07 23:13:45 +01: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 16:16:56 +01:00
|
|
|
}
|
2014-05-31 12:39:35 +02:00
|
|
|
}
|