TagBoardBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * RssBridgeTagBoard
  4. * Search TagBoard for most recent pages regarding a specific topic.
  5. * Returns the most recent links in results, sorting by date (most recent first).
  6. * 2014-09-10
  7. *
  8. * @name TagBoard
  9. * @homepage http://www.TagBoard.com
  10. * @description Returns most recent results from TagBoard.
  11. * @maintainer Pitchoule
  12. * @use1(u="keyword")
  13. */
  14. class TagBoardBridge extends BridgeAbstract{
  15. public function collectData(array $param){
  16. $html = '';
  17. $this->request = $param['u'];
  18. $link = 'https://post-cache.tagboard.com/search/' .$this->request;
  19. $html = file_get_html($link) or $this->returnError('Could not request TagBoard for : ' . $link , 404);
  20. $parsed_json = json_decode($html);
  21. foreach($parsed_json->{'posts'} as $element) {
  22. $item = new Item();
  23. $item->uri = $element->{'permalink'};
  24. $item->title = $element->{'text'};
  25. $item->thumbnailUri = $element->{'photos'}[0]->{'m'};
  26. if (isset($item->thumbnailUri)) {
  27. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a>';
  28. }else{
  29. $item->content = $element->{'html'};
  30. }
  31. $this->items[] = $item;
  32. }
  33. }
  34. public function getName(){
  35. return 'tagboard - ' .$this->request;
  36. }
  37. public function getURI(){
  38. return 'http://TagBoard.com';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }