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
|
|
|
|
2016-06-21 23:33:51 +02: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')
|
|
|
|
or die('Unable to query Rue89 !');
|
|
|
|
$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:13:45 +01:00
|
|
|
public function getArticle($articleInfo) {
|
|
|
|
|
|
|
|
$articleJson = getContents($articleInfo->json_url) or die('Unable to get article !');
|
|
|
|
$article = json_decode($articleJson);
|
|
|
|
$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
|
|
|
}
|
2018-11-07 23:13:45 +01:00
|
|
|
|
2014-05-31 12:39:35 +02:00
|
|
|
}
|