ScoopItBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class ScoopItBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "Pitchoule";
  5. $this->name = "ScoopIt";
  6. $this->uri = "http://www.scoop.it";
  7. $this->description = "Returns most recent results from ScoopIt.";
  8. $this->update = "2014-06-13";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "keyword",
  13. "identifier" : "u"
  14. }
  15. ]';
  16. }
  17. public function collectData(array $param){
  18. $html = '';
  19. if ($param['u'] != '') {
  20. $this->request = $param['u'];
  21. $link = 'http://scoop.it/search?q=' .urlencode($this->request);
  22. $html = $this->file_get_html($link) or $this->returnError('Could not request ScoopIt. for : ' . $link , 404);
  23. foreach($html->find('div.post-view') as $element) {
  24. $item = new Item();
  25. $item->uri = $element->find('a', 0)->href;
  26. $item->title = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
  27. $item->content = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext);
  28. $this->items[] = $item;
  29. }
  30. } else {
  31. $this->returnError('You must specify a keyword', 404);
  32. }
  33. }
  34. public function getName(){
  35. return 'ScooptIt';
  36. }
  37. public function getURI(){
  38. return 'http://Scoop.it';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }