IdenticaBridge.php 1.3 KB

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