Embedding Instagram feed in your website

This post is used to get recent feed from your Instagram account and show them in your website automatically. We retrieve the Instagram feed by calling the Instagram API from any server side language.

It includes generation of Access Token to your app using Instagram developer site and the making calls to Instagram API to get the recent feed. To call the API, we make use of any server side language instead of Javascript as we need to pass Access Token inside the GET request. The Access Token is to be kept secret.

Getting Access Token from Instagram Developer site

Enter the required details and Register. Once your account is successfully created, you should see the CLIENT ID and CLIENT SECRET. Make a note of these details, as they are used to make API request to Instagram to get the feeds.

Then edit the client what we have created. Go to the Security tab and uncheck the ‘Disable implicit OAuth’ and update the client.

Once they are updated, use the below URL and get the access token. Put your client id and redirect URL what you have provided while creation in the URL below.
URL: https://www.instagram.com/oauth/authorize/?clientid=PUTYOURCLIENTIDHERE&redirecturi=YOUR_REDIRECTURL&responsetype=token

You will be asked to authorize your App to use your Instagram account. Click on authorize.

Click on Authorize.

You will be redirected to your redirect URL with the Access token in the URL as shown below.

http://www.logicalfeed.com/#access_token=YOUR_ACCESS_TOKEN_HERE

Make a note and save your Access token. Access token is specific to each user and it should be not be disclosed to anyone.NOTE: By default the app will be in Sandbox mode with some limited number of requests. For more details about Sandbox mode and its limitations, you can go through the Instagram documentation here. Ofcourse you can even continue in the Sandbox mode too.

To test the URL, you can directly run the above URL in the browser and check the response from Instagram API. The output you receive will be JSON format. If it is working, then you can make HTTP GET to this URL from any server side language.Note: Instagram suggests not to make Javascript ajax calls, as this would make the Access token visible to everyone from the browser. So user your favorite server side language to make ajax calls.

I hope you found this useful. So please do SHARE!

About the author

pranay Sitecore Certified Professional

A Software Engineer by profession, a part time blogger and an enthusiast programmer. You can find more about me here.