2014-05-31 12:39:35 +02:00
|
|
|
<?php
|
|
|
|
class Rue89Bridge extends BridgeAbstract{
|
2015-11-05 12:20:11 +01:00
|
|
|
|
|
|
|
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)";
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->update = '2016-08-17';
|
2015-11-05 12:20:11 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-21 23:33:51 +02:00
|
|
|
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"];
|
2015-01-30 19:56:55 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-21 23:33:51 +02:00
|
|
|
public function collectData(array $param){
|
|
|
|
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM('http://api.rue89.nouvelobs.com/feed') or $this->returnServerError('Could not request Rue89.');
|
2015-01-30 19:56:55 +01:00
|
|
|
|
2014-05-31 12:39:35 +02:00
|
|
|
$limit = 0;
|
|
|
|
foreach($html->find('item') as $element) {
|
2016-06-21 23:33:51 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
2014-05-31 12:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|