2013-08-15 11:02:43 +02:00
|
|
|
<?php
|
|
|
|
class IdenticaBridge extends BridgeAbstract{
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2013-08-15 13:58:58 +02:00
|
|
|
private $request;
|
2013-08-15 11:02:43 +02:00
|
|
|
|
2015-11-05 16:50:18 +01:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "mitsukarenai";
|
|
|
|
$this->name = "Identica Bridge";
|
|
|
|
$this->uri = "https://identi.ca/";
|
|
|
|
$this->description = "Returns user timelines";
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->update = '2016-08-17';
|
2015-11-05 16:50:18 +01:00
|
|
|
|
|
|
|
$this->parameters[] =
|
|
|
|
'[
|
|
|
|
{
|
|
|
|
"name" : "username",
|
|
|
|
"identifier" : "u"
|
|
|
|
}
|
|
|
|
]';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-15 11:02:43 +02:00
|
|
|
public function collectData(array $param){
|
|
|
|
$html = '';
|
|
|
|
if (isset($param['u'])) { /* user timeline mode */
|
2013-08-15 13:58:58 +02:00
|
|
|
$this->request = $param['u'];
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM('https://identi.ca/'.urlencode($this->request)) or $this->returnServerError('Requested username can\'t be found.');
|
2013-08-15 11:02:43 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('You must specify an Identica username (?u=...).');
|
2013-08-15 11:02:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach($html->find('li.major') as $dent) {
|
|
|
|
$item = new \Item();
|
|
|
|
$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 = $param['u'] . ' | ' . $item->content;
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
2013-08-15 13:58:58 +02:00
|
|
|
return (!empty($this->request) ? $this->request .' - ' : '') .'Identica Bridge';
|
2013-08-15 11:02:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
|
|
|
return 'https://identica.com';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 300; // 5 minutes
|
|
|
|
}
|
|
|
|
}
|