logo

Widgets Tools Code

Not sure how you got here, possibly by accident, but since you're here you might as well check out my widgets. Anything that I build out that I find useful myself - my theory is, if I might enjoy it, so may you. Cheers.

Instagram

post

Setting Up Instagram feed

Setting your own feed is easier than setting up somebody elses, but still nothing is impossible. Using Instapics you can quickly generate your own user id and access token. Once you have that you can use instafeed.js script to quickly load your own feed. Need somebody else's feed. You can use the PHP script below to extract somebody's user id with their username. Check it out:

<?
function getInstaID($username){
  $username = strtolower($username);
  $token = 'your-access-token-generated-above';
  $url = "https://api.instagram.com/v1/users/search?q=".$username."&access_token=".$token;
  $get = scraper($url);
  $json = json_decode($get);
  
  foreach($json->data as $user){
    if($user->username == $username){
      return $user->id;
    }
  }
  return '00000000';
}
$instagram_id = getInstaID('laurenconrad');
?>
                      

The above code would assign the value of "00000000" to $instagram_id. Now it's just javascript to load the feed into a container with "instafeed" id:

var feed = new Instafeed({
    get: 'user',
    userId: <=$instagram_id;>,
    clientId: your-client-id-generated-above,
    accessToken: 'your-access-token-generated-above',
    limit:60,
    resolution:'standard_resolution',
    links:false,
});
feed.run();
											

It's that simple

Wanna give it a shot? Enter your instagram username below: (examples: barackobama, sleepinthegardn, zozeebo)