IdenticaBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * RssBridgeIdentica
  4. *
  5. * @name Identica Bridge
  6. * @description Returns user timelines
  7. * @maintainer mitsukarenai
  8. * @use1(u="username")
  9. */
  10. class IdenticaBridge extends BridgeAbstract{
  11. private $request;
  12. public function collectData(array $param){
  13. $html = '';
  14. if (isset($param['u'])) { /* user timeline mode */
  15. $this->request = $param['u'];
  16. $html = file_get_html('https://identi.ca/'.urlencode($this->request)) or $this->returnError('Requested username can\'t be found.', 404);
  17. }
  18. else {
  19. $this->returnError('You must specify an Identica username (?u=...).', 400);
  20. }
  21. foreach($html->find('li.major') as $dent) {
  22. $item = new \Item();
  23. $item->uri = html_entity_decode($dent->find('a', 0)->href); // get dent link
  24. $item->timestamp = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp
  25. $item->content = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text
  26. $item->title = $param['u'] . ' | ' . $item->content;
  27. $this->items[] = $item;
  28. }
  29. }
  30. public function getName(){
  31. return (!empty($this->request) ? $this->request .' - ' : '') .'Identica Bridge';
  32. }
  33. public function getURI(){
  34. return 'https://identica.com';
  35. }
  36. public function getCacheDuration(){
  37. return 300; // 5 minutes
  38. }
  39. }