mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-23 18:15:28 +03:00
de1b39c8e5
if a bridge needs to modify some of the data that were initialized there, ::__construct() should be used instead. Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
class Rue89Bridge extends BridgeAbstract{
|
|
|
|
public $maintainer = "pit-fgfjiudghdf";
|
|
public $name = "Rue89";
|
|
public $uri = "http://rue89.nouvelobs.com/";
|
|
public $description = "Returns the 5 newest posts from Rue89 (full text)";
|
|
|
|
private function rue89getDatas($url){
|
|
|
|
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($url, -8)) . "/full";
|
|
$datas = json_decode($this->getContents($url), true);
|
|
|
|
return $datas["node"];
|
|
|
|
}
|
|
|
|
public function collectData(){
|
|
|
|
$html = $this->getSimpleHTMLDOM('http://api.rue89.nouvelobs.com/feed') or $this->returnServerError('Could not request Rue89.');
|
|
|
|
$limit = 0;
|
|
foreach($html->find('item') as $element) {
|
|
|
|
if($limit < 5) {
|
|
|
|
$datas = $this->rue89getDatas(str_replace('#commentaires', '', ($element->find('comments', 0)->plaintext)));
|
|
|
|
$item = array();
|
|
$item['title'] = $datas["title"];
|
|
$item['author'] = $datas["author"][0]["name"];
|
|
$item['timestamp'] = $datas["updated"];
|
|
$item['content'] = $datas["body"];
|
|
$item['uri'] = $datas["url"];
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|