mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03:00
955eecc299
instead of simple_html_dom function file_get_html Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
class Rue89Bridge extends BridgeAbstract{
|
|
|
|
public function loadMetadatas() {
|
|
|
|
$this->maintainer = "pit-fgfjiudghdf";
|
|
$this->name = "Rue89";
|
|
$this->uri = "http://rue89.nouvelobs.com/";
|
|
$this->description = "Returns the 5 newest posts from Rue89 (full text)";
|
|
$this->update = "2015-01-30";
|
|
|
|
}
|
|
|
|
private function rue89getDatas($url){
|
|
|
|
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($url, -8)) . "/full";
|
|
$datas = json_decode(file_get_contents($url), true);
|
|
|
|
return $datas["node"];
|
|
|
|
}
|
|
|
|
public function collectData(array $param){
|
|
|
|
$html = $this->file_get_html('http://api.rue89.nouvelobs.com/feed') or $this->returnError('Could not request Rue89.', 404);
|
|
|
|
$limit = 0;
|
|
foreach($html->find('item') as $element) {
|
|
|
|
if($limit < 5) {
|
|
|
|
$datas = $this->rue89getDatas(str_replace('#commentaires', '', ($element->find('comments', 0)->plaintext)));
|
|
|
|
$item = new \Item();
|
|
$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;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
public function getName(){
|
|
return 'Rue89';
|
|
}
|
|
public function getURI(){
|
|
return 'http://rue89.nouvelobs.com/';
|
|
}
|
|
public function getCacheDuration(){
|
|
return 3600; // 1 hour
|
|
}
|
|
}
|