IdenticaBridge.php 1.3 KB

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