On June 29th, web developers and admins of the world were reminded that Facebook owns Instagram. The legacy API methods to simply get the dang content of an Instagram user were disabled, and the new Facebook-entangled API was required. And, depending on your employer, you were, at that time, also reminded of the importance of Social Media to your company, or you weren’t because it’s not important.
To fix the feed, you will need the following:
- A Facebook Account (see how they pull you back in?)
- Enrollment of your FB account as a Facebook Developer
- Access to your company’s Instagram account
To start, go to My Apps on the Facebook Developer Dashboard, and Add a New App:
In the options pop-up, choose For Everything Else:
Enter the app name and the email address that FB will contact if you turn your app into malware.
Users of more…established (top-heavy) companies will likely have a Business Manager account to select in the 3rd field of this pop-up, in which case you need to select that here in order to access the content later.
Now, in the dashboard of the app you just created you will need to select a product. We will click the Set Up button for Instagram Basic Display:
Go to the Basic settings of the App:
What website you enter is not important, because it will just be redirect there to give you a token, but how you enter it is important because the way it is entered in later API calls needs to match the way you enter it here. Be sure to Save Changes via the blue button at the bottom right of the page.
Next we are going into the Instagram Basic Display product we created to create…an App! Yes, it’s an App within an App, so let’s just call it the sub-app.
I don’t know if it matters what we call this sub-app, but I gave it the same name because it was existentially easier to consider:
Fill in the sub-app’s settings, providing the same URL as Website Platform URL that you provided earlier. You can see I left a slash off of my entries and it didn’t matter.
Also, click both Add to Submission options to give the Sub-app access to your content; Instagram_graph_user_profile, and Instagram_graph_user_media. Our app will never be submitted for review but the API will still complain without these.
Back in the sidebar of the app (not the sub-app), click Roles to add an Instagram Test User; this will be used as the account that receives the invitation to use the app.
I would simply add the Instagram user of the account you want to get the feed from. What’s more Basic than that?
Log into the Instagram account, and under Settings, find the Apps and Websites option, and then the Tester Invites, and accept the invitation:
Once the Instagram Test User is added, you can generate an access token under the Basic Display option of the sidebar, which shows the sub-app’s info and settings:
When you click the button, an Instagram login pop-up will appear, and you will have to login the Instagram account and permit the access:
Once that’s done, you will FINALLY see the Access Token in the following pop-up, which will make you tell the computer you understand that this is a Security Matter of Great Importance to access what is most likely a public facing page, before you’re allowed to see and copy the token value. Put the value in a SAFE!!/convenient place.
With this token, you can get are the data of your Instagram, but you will need first to get your user id. This can be retrieved via the following call:
https://graph.instagram.com/me?access_token=[YOUR SUPER-SECRET ACCESS TOKEN]
…This call will return a single piece of data: your Instagram User ID, which you can then provide to calls to get content, such as retrieving recent posts:
https://graph.instagram.com/[YOUR HARD-TO-FIND USER ID]/media?access_token=[YOUR SUPER-SECRET ACCESS TOKEN]
…This call will return the id’s of latest 10 posts from the Instagram account.
The media of each post needs to be retrieved from another call:
https://graph.instagram.com/[THE RETRIEVED POST ID]?fields=id,media_type,media_url,username,timestamp,caption&access_token=[YOUR SUPER-SECRET ACCESS TOKEN]
…This call will return the media_type; IMAGE or VIDEO; and the media_url to finally show some content from you likely-public facing Instagram page.
Oh, the comments and like counts aren’t supported by the Basic Display API. It’s possible to get this info via the Facebook graph, but that’s beyond the scope of this walk-thru.