TagBoardBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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->update = "2014-09-10";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "keyword",
  13. "identifier" : "u"
  14. }
  15. ]';
  16. }
  17. public function collectData(array $param){
  18. $html = '';
  19. $this->request = $param['u'];
  20. $link = 'https://post-cache.tagboard.com/search/' .$this->request;
  21. $html = $this->file_get_html($link) or $this->returnError('Could not request TagBoard for : ' . $link , 404);
  22. $parsed_json = json_decode($html);
  23. foreach($parsed_json->{'posts'} as $element) {
  24. $item = new Item();
  25. $item->uri = $element->{'permalink'};
  26. $item->title = $element->{'text'};
  27. $item->thumbnailUri = $element->{'photos'}[0]->{'m'};
  28. if (isset($item->thumbnailUri)) {
  29. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a>';
  30. }else{
  31. $item->content = $element->{'html'};
  32. }
  33. $this->items[] = $item;
  34. }
  35. }
  36. public function getName(){
  37. return 'tagboard - ' .$this->request;
  38. }
  39. public function getURI(){
  40. return 'http://TagBoard.com';
  41. }
  42. public function getCacheDuration(){
  43. return 21600; // 6 hours
  44. }
  45. }