[TwitterBridge] fix getURI() and simplify code
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
85625318b1
commit
ea46d532dc
1 changed files with 13 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class TwitterBridge extends BridgeAbstract{
|
class TwitterBridge extends BridgeAbstract{
|
||||||
public $name='Twitter Bridge';
|
public $name='Twitter Bridge';
|
||||||
public $uri='https://twitter.com';
|
public $uri='https://twitter.com/';
|
||||||
public $description='returns tweets';
|
public $description='returns tweets';
|
||||||
public $parameters=array(
|
public $parameters=array(
|
||||||
'global'=>array(
|
'global'=>array(
|
||||||
|
@ -53,28 +53,27 @@ class TwitterBridge extends BridgeAbstract{
|
||||||
$params=$this->parameters[$this->queriedContext];
|
$params=$this->parameters[$this->queriedContext];
|
||||||
switch($this->queriedContext){
|
switch($this->queriedContext){
|
||||||
case 'By keyword or hashtag':
|
case 'By keyword or hashtag':
|
||||||
return $this->uri.'search?q='.urlencode($params['q']['value']);
|
return $this->uri.'search?q='.urlencode($params['q']['value']).'&f=tweets';
|
||||||
case 'By username':
|
case 'By username':
|
||||||
return $this->uri.urlencode($params['u']['value']).
|
return $this->uri.urlencode($params['u']['value']).
|
||||||
(isset($params['norep']['value'])?'':'/with_replies');
|
($params['norep']['value']?'':'/with_replies');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$param=$this->parameters[$this->queriedContext];
|
$param=$this->parameters[$this->queriedContext];
|
||||||
$html = '';
|
$html = '';
|
||||||
if (isset($param['q']['value'])) { /* keyword search mode */
|
|
||||||
$html = $this->getSimpleHTMLDOM('https://twitter.com/search?q='.urlencode($param['q']['value']).'&f=tweets') or $this->returnServerError('No results for this query.');
|
$html = $this->getSimpleHTMLDOM($this->getURI());
|
||||||
|
if(!$html){
|
||||||
|
switch($this->queriedContext){
|
||||||
|
case 'By keyword or hashtag':
|
||||||
|
$this->returnServerError('No results for this query.');
|
||||||
|
case 'By username':
|
||||||
|
$this->returnServerError('Requested username can\'t be found.');
|
||||||
}
|
}
|
||||||
elseif (isset($param['u']['value'])) { /* user timeline mode */
|
|
||||||
$html = $this->getSimpleHTMLDOM('https://twitter.com/'.urlencode($param['u']['value']).(isset($param['norep']['value'])?'':'/with_replies')) or $this->returnServerError('Requested username can\'t be found.');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->returnClientError('You must specify a keyword (?q=...) or a Twitter username (?u=...).');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$hidePictures = false;
|
|
||||||
if (isset($param['nopic']['value']))
|
|
||||||
$hidePictures = $param['nopic']['value'];
|
$hidePictures = $param['nopic']['value'];
|
||||||
|
|
||||||
foreach($html->find('div.js-stream-tweet') as $tweet) {
|
foreach($html->find('div.js-stream-tweet') as $tweet) {
|
||||||
|
|
Loading…
Reference in a new issue