TagBoardBridge.php 1.2 KB

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