Rss-Bridge/bridges/IdenticaBridge.php
Pierre Mazière 1b3c8a8aeb [core + bridges] add BridgeAbstract::$inputs and BridgeAbstract::getInput()
Inputs are not stored in BridgeAbstract::$parameters anymore to separate
static data from dynamic data.
The getInput method allows for more readable code.

Also fix an "undefined index 'global'" notice

Probability of breaking bridges: high !

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-08-28 13:05:03 +02:00

43 lines
1.3 KiB
PHP

<?php
class IdenticaBridge extends BridgeAbstract{
public $maintainer = "mitsukarenai";
public $name = "Identica Bridge";
public $uri = "https://identi.ca/";
public $description = "Returns user timelines";
public $parameters = array( array(
'u'=>array(
'name'=>'username',
'required'=>true
)
));
public function collectData(){
$html = '';
$html = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent) {
$item = array();
$item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link
$item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text
$item['title'] = $this->getInput('u') . ' | ' . $item['content'];
$this->items[] = $item;
}
}
public function getName(){
return $this->getInput('u') .' - Identica Bridge';
}
public function getURI(){
return $this->uri.urlencode($this->getInput('u'));
}
public function getCacheDuration(){
return 300; // 5 minutes
}
}