TagBoardBridge.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class TagBoardBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "Pitchoule";
  5. $this->name = "TagBoard";
  6. $this->uri = "http://www.TagBoard.com";
  7. $this->description = "Returns most recent results from TagBoard.";
  8. $this->parameters[] = array(
  9. 'u'=>array(
  10. 'name'=>'keyword',
  11. 'required'=>true
  12. )
  13. );
  14. }
  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 = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request TagBoard for : ' . $link);
  20. $parsed_json = json_decode($html);
  21. foreach($parsed_json->{'posts'} as $element) {
  22. $item = array();
  23. $item['uri'] = $element->{'permalink'};
  24. $item['title'] = $element->{'text'};
  25. $thumbnailUri = $element->{'photos'}[0]->{'m'};
  26. if (isset($thumbnailUri)) {
  27. $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $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 getCacheDuration(){
  38. return 21600; // 6 hours
  39. }
  40. }