1
0
Fork 0
forked from blallo/rss-bridge

Add hashtag support to InstagramBridge.

Fixes  #629
This commit is contained in:
teromene 2018-03-19 12:29:24 +00:00
parent 29c690dbcd
commit 38c7e0272e

View file

@ -6,7 +6,8 @@ class InstagramBridge extends BridgeAbstract {
const URI = 'https://instagram.com/'; const URI = 'https://instagram.com/';
const DESCRIPTION = 'Returns the newest images'; const DESCRIPTION = 'Returns the newest images';
const PARAMETERS = array( array( const PARAMETERS = array(
array(
'u' => array( 'u' => array(
'name' => 'username', 'name' => 'username',
'required' => true 'required' => true
@ -22,7 +23,25 @@ class InstagramBridge extends BridgeAbstract {
), ),
'defaultValue' => 'all' 'defaultValue' => 'all'
) )
)); ),
array(
'h' => array(
'name' => 'hashtag',
'required' => true
),
'media_type' => array(
'name' => 'Media type',
'type' => 'list',
'required' => false,
'values' => array(
'Both' => 'all',
'Video' => 'video',
'Picture' => 'picture'
),
'defaultValue' => 'all'
)
)
);
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
@ -47,7 +66,11 @@ class InstagramBridge extends BridgeAbstract {
$json = trim(substr($innertext, $pos + 18), ' =;'); $json = trim(substr($innertext, $pos + 18), ' =;');
$data = json_decode($json); $data = json_decode($json);
if(!is_null($this->getInput('u'))) {
$userMedia = $data->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges; $userMedia = $data->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges;
} else {
$userMedia = $data->entry_data->TagPage[0]->graphql->hashtag->edge_hashtag_to_media->edges;
}
foreach($userMedia as $media) { foreach($userMedia as $media) {
$media = $media->node; $media = $media->node;
@ -87,6 +110,8 @@ class InstagramBridge extends BridgeAbstract {
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u'))) { if(!is_null($this->getInput('u'))) {
return self::URI . urlencode($this->getInput('u')); return self::URI . urlencode($this->getInput('u'));
} elseif(!is_null($this->getInput('h'))) {
return self::URI . 'explore/tags/' . urlencode($this->getInput('h'));
} }
return parent::getURI(); return parent::getURI();