How to Get Instagram Photos by Tag and of any User without Access Token
And now let me disappoint you, just for a little β WordPress only. π
The code below is a wrapper of my hardcoded functions, that are interacting with WordPress HTTP API and process the result.
No more words, let’s code.
By a Tag. No Access Token required
You can use the below code just in a place where you would like to display photos.
$instagram = new mishaInstagram();
$by_tag = $instagram->serve_tag_media( 'dombay', 30 ); // 30 is how much photos you would like to display
// your can just prin_r() the result to view all the parameters
// print_r( $by_tag );
if( !is_wp_error( $by_tag ) ) {
$html = '';
foreach ( $by_tag['response'] as $photo ) {
$html .= '- '; // instagram link
$html .= '
'; // hi-res photo: $photo['display_url']
$html .= ' ';
// $photo['taken_at_timestamp'] β publish date
// $photo['dimensions']['height'] and $photo['dimensions']['width'] β original height and width
// $photo['edge_media_to_caption']['edges'][0]['node']['text'] β caption :D
// $photo['edge_liked_by']['count'] β number of likes
// $photo['edge_media_to_comment']['count'] βΒ number of comments
// print_r( $photo ) βΒ for more parameters
}
$html .= '
';
echo $html;
}
But what is mishaInstagram()
? This class makes all the nasty job β it is the part of my plugin you have to install first to make this code work.
Photos from any user. No Access Token again
This code is very similar to the previous one where we get photos by a tag.
$instagram = new mishaInstagram();
$user_photos = $instagram->serve_user( 'rudrastyh', 10 );
print_r( $user_photos['media'] );
How to find out an Instagram user ID?
Earlier you could get Instagram user ID from html code on his profile page. It is not possible anymore. But the below code will help you:
$instagram = new mishaInstagram();
$user = $instagram->serve_user( 'rudrastyh' ); // get user info as an array
echo $user['profile']['pk']; // profile ID
P.S. I forgot when last time I published a tutorial to promote my plugins, half-year ago or so. But my website doesn’t have any ads π and the next tutorial is going to be awesome π₯

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
I’m running this:
and the results are as follows:
What am I doing wrong?
Hi,
I do not know why but your response seems stripped down. I tried your code on my test website and everything seems OK.
If you are still experiencing this problem, please create a ticket and me your website ftp access please.
Hey misha, is tis working correctly, instagram ha been flagging server IPs banning requests for whoever is trying to scrape…. i was using riyams instagram scraper php and now i get a wierd error
Hey Lorenzo,
Instagram doesn’t flag this solution, because it caches the result.
And how did I get one?