IdenticaBridge.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. $item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link
  20. $item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp
  21. $item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text
  22. $item['title'] = $this->getInput('u') . ' | ' . $item['content'];
  23. $this->items[] = $item;
  24. }
  25. }
  26. public function getName(){
  27. return $this->getInput('u') .' - Identica Bridge';
  28. }
  29. public function getURI(){
  30. return self::URI.urlencode($this->getInput('u'));
  31. }
  32. }