9
votes

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?

2
Im looking for exactly the same thing. The code is easy to create to get your feed but it requires the user to login - which is not what I need. Did you find a work around for this? - Jonathan
looking for the same thing too. - wsgg

2 Answers

4
votes

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
0
votes

Checkout this Youtube-Tutorial of Justin Stolpe, there you find a step by step instruction to build a Instagram Feed using Instagram Basic Display API (or Graph API)