TagBoardBridge.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class TagBoardBridge extends BridgeAbstract{
  3. const MAINTAINER = "Pitchoule";
  4. const NAME = "TagBoard";
  5. const URI = "http://www.TagBoard.com/";
  6. const DESCRIPTION = "Returns most recent results from TagBoard.";
  7. const PARAMETERS = array( array(
  8. 'u'=>array(
  9. 'name'=>'keyword',
  10. 'required'=>true
  11. )
  12. ));
  13. public function collectData(){
  14. $link = 'https://post-cache.tagboard.com/search/' .$this->getInput('u');
  15. $html = getSimpleHTMLDOM($link)
  16. or returnServerError('Could not request TagBoard for : ' . $link);
  17. $parsed_json = json_decode($html);
  18. foreach($parsed_json->{'posts'} as $element) {
  19. $item = array();
  20. $item['uri'] = $element->{'permalink'};
  21. $item['title'] = $element->{'text'};
  22. $thumbnailUri = $element->{'photos'}[0]->{'m'};
  23. if (isset($thumbnailUri)) {
  24. $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
  25. }else{
  26. $item['content'] = $element->{'html'};
  27. }
  28. $this->items[] = $item;
  29. }
  30. }
  31. public function getName(){
  32. return 'tagboard - ' .$this->getInput('u');
  33. }
  34. public function getCacheDuration(){
  35. return 21600; // 6 hours
  36. }
  37. }