Skip to content

IG Hashtag Recent Media

Justin Stolpe edited this page May 21, 2022 · 4 revisions

Get the most recent media published for a given hashtag.

Code

use Instagram\Hashtag\RecentMedia;
use Instagram\Request\Params;

$config = array( // instantiation config params
    'user_id' => '<USER_ID>',
    'hashtag_id' => '<HASHTAG_ID>', // id of the hashtag
    'access_token' => '<ACCESS_TOKEN>',
);

// instantiate recent media for the hashtag
$recentMedia = new RecentMedia( $config );

// recent media for a hashtag
$recentMediaForHashtag = $recentMedia->getSelf();

if ( $recentMedia->pagingNextLink ) { // get next page
    $nextPage = $recentMedia->getPage( Params::NEXT );
}

if ( $recentMedia->pagingPreviousLink ) { // get prev page
    $prevPage = $recentMedia->getPage( Params::PREV );
}
Clone this wiki locally