VineBridge.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class VineBridge extends BridgeAbstract {
  3. const MAINTAINER = "ckiw";
  4. const NAME = "Vine bridge";
  5. const URI = "http://vine.co/";
  6. const DESCRIPTION = "Returns the latests vines from vine user page";
  7. const PARAMETERS = array( array(
  8. 'u'=>array(
  9. 'name'=>'User id',
  10. 'required'=>true
  11. )
  12. ));
  13. public function collectData(){
  14. $html = '';
  15. $uri = self::URI.'/u/'.$this->getInput('u').'?mode=list';
  16. $html = getSimpleHTMLDOM($uri)
  17. or returnServerError('No results for this query.');
  18. foreach($html->find('.post') as $element) {
  19. $a = $element->find('a', 0);
  20. $a->href = str_replace('https://', 'http://', $a->href);
  21. $time = strtotime(ltrim($element->find('p', 0)->plaintext, " Uploaded at "));
  22. $video = $element->find('video', 0);
  23. $video->controls = "true";
  24. $element->find('h2', 0)->outertext = '';
  25. $item = array();
  26. $item['uri'] = $a->href;
  27. $item['timestamp'] = $time;
  28. $item['title'] = $a->plaintext;
  29. $item['content'] = $element;
  30. $this->items[] = $item;
  31. }
  32. }
  33. }