Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Instagram feed of any user with new Graph API?

Facebook recently introduced Instagram Graph API, which allows to fetch data from Instagram page that is connected to your Facebook company page, instagram.com/developers states:

The Instagram Graph API is Now Available to All Developers.
For Non-Business Instagram Accounts please continue to use the existing Instagram API.

So, for example, if my company has account instagram.com/my_first_company, I can only retrieve its feed and no one else.

Using old Instagram API to retrieve public_content permission (access to any feed) is no longer an option too, from old API documetation:

public_content - to read any public profile info and media on a user’s behalf (applications no longer accepted)


  • What will happen to existing tools that have public_content permission? (for example, there are tons of plugins for various CMS that allow to display recent Instagram photos)
  • Is there any valid way to access public_content (access to any feed) right now (besides fetching HTML pages of Instagram website)?
  • Are there any plans to enable Graph API for non-business customers, of so when?

UPD. There seem to be ?__a=1 endpoint that allows to get access to recent photos of any public feed without any tokens. But it's not official and no one knows when/if Instagram will close it. If you do - please let me know.

UPD 2. Instagram removed ?__a=1 endpoint, not sure for how long, probably forever. Currently the only way to access instagram feed is to scrap instagram.com website, which is a horror.

like image 307
Marvin3 Avatar asked Oct 08 '17 19:10

Marvin3


People also ask

Can you access Instagram API?

In 2018, Instagram shut down its public API. Meaning, third-party apps can no longer access the API from Instagram without permission. Third-party apps now need to be approved by Instagram before they can access the API.


Video Answer


2 Answers

Prerequisite: You first need the business Instagram account to be linked with FB Page. https://help.instagram.com/356902681064399 - That one can do from the profile page of Instagram account.

  • Get the Instagram business account id: graph.facebook.com/v2.8/<fbPageId>?fields=instagram_business_account. (the fbPageId is the page id of the facebook page the account is linked)

  • To fetch instagram media feed: graph.facebook.com/v2.8/<igBusinessId>/media to fetch the media feed of the Instagram account. (the igBusinessId is the id returned in above linked instagram_business_account) - This is still owned media as per the page access_token. Not any other user's feed.

  • All other endpoints (such as comments moderation, detailed insights API) mentioned here works on the business media list returned on above call.

Please note: This still does not allow to fetch un-authenticated user's Instagram feed. That is not possible via API now. There is no valid way via API to get to public_content scope. There can be few Instagram Marketing partners for which this is enabled. But, in general the scope is deprecated now!

Currently, for FB graph API to work we need linked business page to Instagram account. As above apis uses page tokens.

like image 112
enator Avatar answered Oct 06 '22 21:10

enator


You can get information about any IG business account using your FB access_token using the business_discovery API as given here.

  • You must have an IG business account to read other users data like user_info or media details using the id of your IG business account as a node.

Ex:

GET graph.facebook.com/[YOUR-IG-BUSINESS-ACCOUNT-ID]?fields=business_discovery.username(USERNAME){media{caption,media_url,media_type,like_count,comments_count,id}}

like image 40
rakeshpatra Avatar answered Oct 06 '22 19:10

rakeshpatra