rss-bridge/bridges/VineBridge.php
Pierre Mazière 1b3c8a8aeb [core + bridges] add BridgeAbstract::$inputs and BridgeAbstract::getInput()
Inputs are not stored in BridgeAbstract::$parameters anymore to separate
static data from dynamic data.
The getInput method allows for more readable code.

Also fix an "undefined index 'global'" notice

Probability of breaking bridges: high !

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-08-28 13:05:03 +02:00

44 lines
1.1 KiB
PHP

<?php
class VineBridge extends BridgeAbstract {
public $maintainer = "ckiw";
public $name = "Vine bridge";
public $uri = "http://vine.co/";
public $description = "Returns the latests vines from vine user page";
public $parameters = array( array(
'u'=>array(
'name'=>'User id',
'required'=>true
)
));
public function collectData(){
$html = '';
$uri = 'http://vine.co/u/'.$this->getInput('u').'?mode=list';
$html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for this query.');
foreach($html->find('.post') as $element) {
$a = $element->find('a', 0);
$a->href = str_replace('https://', 'http://', $a->href);
$time = strtotime(ltrim($element->find('p', 0)->plaintext, " Uploaded at "));
$video = $element->find('video', 0);
$video->controls = "true";
$element->find('h2', 0)->outertext = '';
$item = array();
$item['uri'] = $a->href;
$item['timestamp'] = $time;
$item['title'] = $a->plaintext;
$item['content'] = $element;
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 10; //seconds
}
}