Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram Feed in website - using Instagram Basic Display API

I am trying to show instagram feed(of a specific account) on website using the developer documentation at https://developers.facebook.com/docs/instagram-basic-display-api/getting-started . instagram-basic-display-api seems supporting "Getting an Instagram user’s images, videos, and albums".

Manually through browser I could get the Authorization code by clicking "Authorize" in the Authorization Window. But it's mentioned in the post that "Authorization codes are short-lived and are only valid for 1 hour.". And hence I couldn't reuse the same authorization code for all the requests and every hour I need to generate a new one. Is there a way or javascript sdk that allows to make the request through code(javascript) to generate authorization code without Authorization Window?

like image 686
Avenger Avatar asked Nov 23 '19 19:11

Avenger


People also ask

What can you do with Instagram basic display API?

The Instagram Basic Display API allows users of your app to get basic profile information, photos, and videos in their Instagram accounts. The API can be used to access any type of Instagram account but only provides read-access to basic data.

How do you make a basic screen on Instagram?

Go to Dashboard, scroll down, locate the Instagram product, and click Set Up to add it to your app. Click Basic Display, scroll to the bottom of the page, then click Create New App. In the form that appears, complete each section using the guidelines below.

What type of API does Instagram use?

If you are building an app for consumers or you only need to get an app user's basic profile information, photos, and videos, consider the Instagram Basic Display API instead. The API is built on the Facebook Graph API.


1 Answers

Facebook will let you generate a CODE through the browser (GET). Then you will need to exchange mentioned CODE for a TOKEN, but now through cURL request (you can use POSTMAN, for example). as in Step 5: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

If you're using Postman, make sure you put the required parameters in the body as x-www-form-urlencoded.

After Step 5 you may receive an access_token, which you will then be able to query the user. It's a short-lived TOKEN.

As for your question, you would then be able to exchange this short-lived token for a long-lived one, as in https://developers.facebook.com/docs/instagram-basic-display-api/guides/long-lived-access-tokens.

But there are some caveats:

  1. your app must be granted instagram_graph_user_profile
  2. the exchange should only be made in server-side code
  3. expired short-lived tokens cannot be exchanged
  4. long-lived tokens only last 60 days, they need to be refreshed once in a while
  5. if one expires, you can't refresh it
like image 106
luiscabus Avatar answered Sep 23 '22 23:09

luiscabus