IdenticaBridge.php 1.6 KB

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