2014-05-31 14:39:35 +04:00
|
|
|
<?php
|
|
|
|
class Rue89Bridge extends BridgeAbstract{
|
2015-11-05 14:20:11 +03:00
|
|
|
|
2016-08-27 22:03:26 +03:00
|
|
|
public $maintainer = "pit-fgfjiudghdf";
|
|
|
|
public $name = "Rue89";
|
|
|
|
public $uri = "http://rue89.nouvelobs.com/";
|
|
|
|
public $description = "Returns the 5 newest posts from Rue89 (full text)";
|
2015-11-05 14:20:11 +03:00
|
|
|
|
2016-06-22 00:33:51 +03:00
|
|
|
private function rue89getDatas($url){
|
|
|
|
|
|
|
|
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($url, -8)) . "/full";
|
2016-08-23 00:39:40 +03:00
|
|
|
$datas = json_decode($this->getContents($url), true);
|
2016-06-22 00:33:51 +03:00
|
|
|
|
|
|
|
return $datas["node"];
|
2015-01-30 21:56:55 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-06-22 00:33:51 +03:00
|
|
|
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM('http://api.rue89.nouvelobs.com/feed') or $this->returnServerError('Could not request Rue89.');
|
2015-01-30 21:56:55 +03:00
|
|
|
|
2014-05-31 14:39:35 +04:00
|
|
|
$limit = 0;
|
|
|
|
foreach($html->find('item') as $element) {
|
2016-06-22 00:33:51 +03:00
|
|
|
|
|
|
|
if($limit < 5) {
|
|
|
|
|
|
|
|
$datas = $this->rue89getDatas(str_replace('#commentaires', '', ($element->find('comments', 0)->plaintext)));
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['title'] = $datas["title"];
|
|
|
|
$item['author'] = $datas["author"][0]["name"];
|
|
|
|
$item['timestamp'] = $datas["updated"];
|
|
|
|
$item['content'] = $datas["body"];
|
|
|
|
$item['uri'] = $datas["url"];
|
2016-06-22 00:33:51 +03:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
|
|
|
|
}
|
2014-05-31 14:39:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|