ScoopItBridge.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class ScoopItBridge extends BridgeAbstract{
  3. const MAINTAINER = "Pitchoule";
  4. const NAME = "ScoopIt";
  5. const URI = "http://www.scoop.it/";
  6. const DESCRIPTION = "Returns most recent results from ScoopIt.";
  7. const PARAMETERS = array( array(
  8. 'u'=>array(
  9. 'name'=>'keyword',
  10. 'required'=>true
  11. )
  12. ));
  13. public function collectData(){
  14. $this->request = $this->getInput('u');
  15. $link = self::URI.'search?q=' .urlencode($this->getInput('u'));
  16. $html = getSimpleHTMLDOM($link)
  17. or returnServerError('Could not request ScoopIt. for : ' . $link);
  18. foreach($html->find('div.post-view') as $element) {
  19. $item = array();
  20. $item['uri'] = $element->find('a', 0)->href;
  21. $item['title'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_title',0)->plaintext);
  22. $item['content'] = preg_replace('~[[:cntrl:]]~', '', $element->find('div.tCustomization_post_description', 0)->plaintext);
  23. $this->items[] = $item;
  24. }
  25. }
  26. public function getCacheDuration(){
  27. return 21600; // 6 hours
  28. }
  29. }