IdenticaBridge.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class IdenticaBridge extends BridgeAbstract {
  3. const MAINTAINER = 'mitsukarenai';
  4. const NAME = 'Identica Bridge';
  5. const URI = 'https://identi.ca/';
  6. const CACHE_TIMEOUT = 300; // 5min
  7. const DESCRIPTION = 'Returns user timelines';
  8. const PARAMETERS = array( array(
  9. 'u' => array(
  10. 'name' => 'username',
  11. 'required' => true
  12. )
  13. ));
  14. public function collectData(){
  15. $html = getSimpleHTMLDOM($this->getURI())
  16. or returnServerError('Requested username can\'t be found.');
  17. foreach($html->find('li.major') as $dent) {
  18. $item = array();
  19. // get dent link
  20. $item['uri'] = html_entity_decode($dent->find('a', 0)->href);
  21. // extract dent timestamp
  22. $item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext);
  23. // extract dent text
  24. $item['content'] = trim($dent->find('div.activity-content', 0)->innertext);
  25. $item['title'] = $this->getInput('u') . ' | ' . $item['content'];
  26. $this->items[] = $item;
  27. }
  28. }
  29. public function getName(){
  30. if(!is_null($this->getInput('u'))) {
  31. return $this->getInput('u') . ' - Identica Bridge';
  32. }
  33. return parent::getName();
  34. }
  35. public function getURI(){
  36. if(!is_null($this->getInput('u'))) {
  37. return self::URI . urlencode($this->getInput('u'));
  38. }
  39. return parent::getURI();
  40. }
  41. }