1
0

IdenticaBridge.php 1.5 KB

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