Credentials to Fetch Account's Latest Images Using New Instagram Graph API? - facebook-graph-api

I'm trying to display a gallery of images on a website for a client. Those images should be fetched from their Instagram account automatically. Simple, right? Well, it used to be...
I can't use the Instagram API, because it's being deprecated: https://www.instagram.com/developer/
So instead, I'm trying to use the Instagram Graph API to get the latest images for the account: https://developers.facebook.com/docs/instagram-api/reference/user/media#get-media
Skip to the bottom for the short version, or keep reading for the long version.
Long Story
Trouble is, I'm having a very hard time understanding how to even get the credentials to interact with this API. As best I can tell, I need to create four separate things first:
An Instagram Business Account (done)
A Facebook User (done)
A Facebook Page (done)
A Facebook App (done...ish)
I'm not even sure if I need to create all of those things (especially the app), but that's where I'm at now. And I'm trying to figure out what permissions I need based on this page: https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
I'd think I need an "app access token", and from what I understand I can instead use the app ID and app secret combined in place of the app access token, and that actually seemed to sort of work.
I then tried to get the Instagram ID I need based on the linked Facebook page, which I did with this call (with the real Facebook account ID and the proper token): https://graph.facebook.com/some-facebook-account-id-here?fields=instagram_business_account&access_token=something-here|and-here
The response to that call was:
{
"error": {
"message": "(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "[redacted]"
}
}
And then I went down a rabbit hole of trying to submit the "feature" for review, but that ended with me running into a catch 22 where it was asking me to have a live working demo of the thing I'm asking for access to. I don't understand how I can have a live working demo when I don't even have access to it yet.
Long Story Short
Long story short, this seems obscenely complicated for something that should be very simple. Maybe I'm just doing this wrong?
What would you do if you were in my shoes in order to gain access to the
Instagram Graph API so that you can fetch a few images from a specific Instagram account to display on a website?

Now if you want to access Instagram post you have two options
To use Instagram Graph API For Business Account
To use Instagram Platform API For non-business account
Assuming you have business account
Here is link to get started
Note:-
None business account Instagram supports only basic permission
Starting 10/1/2017, all permissions other than the basic permission
will be unavailable to submit for or obtain.
This is what they have to say about Instagram api for non-business accounts
Even on Facebook developers plateform they say
The Instagram Graph API allows you to programmatically access
Instagram Business Accounts
Here is SO thread that discusses about it,
So, in short, it's very hard to use APIs for Non-Business accounts

Related

Requirements for Instagram Graph API testing and development

I'm trying to build a prototype which collects and analyses comments from Instagram. This can seemingly only be done with the Instagram Graph API. So to prototype and test I need:
A business IG account connected to a Facebook account (the account to access and read the comments of)
A Facebook App configured to access IG accounts (the account/app which gets authenticated to access the IG account)
However, this App needs to go through a verification process for each of the permissions required. The process apparently takes up to 5 days and needs a Privacy Policy on a website (neither of which I have yet).
This is a lot to do considering it is just a prototype/PoC to establish feasability and get better acquainted with using/testing the API and data.
Does anyone with experience working with the Instagram Graph API know whether I am over-thinking or misread what is required here? Or do you have to go through this before being able to access IG account comments?

Extract my timeline posts from Facebook Graph API

I am trying to extract my posts, via Graph API from facebook. I used some basic code snippets but they don't work. I can not get my feed even in the Graph Explorer. It always says that I don;t have the permission and I have to submit my App for review and provide a video tutorial on how I use the extracted posts.
But I want to extract just my posts, I don't care for anybody elses. Do I seriously need FB App review to do that?
This is what I get with my token from my app:
user/posts requires additional contract signing:
Use /me/posts with your own App, with your User Token and authorize with the user_posts permission. This works without any approval from Facebook - for your account and your App only, of course. I just tested if it still works in the Graph API Explorer and it did: https://developers.facebook.com/tools/explorer/108138225915615/?method=GET&path=me%2Fposts&version=v5.0

Obtaining Access Token Server Side Instagram Graph Api V3

What I'm trying to achieve:
Fetch images from my own Instagram business account to display on a website using the Instagram graph api v3.3 by not obtaining a user access token from a client side Facebook SDK login modal because users just shouldn't be doing that to see a simple Instagram feed.
I have the permissions manage_pages and instagram_basic granted(gone through app review). I'm using app_id and app_secret as user access_token parameter value(which may not be the access token Instagram graph api is looking for) as when I tried to fetch any data there is an error message:
" #10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.'" However, I don't need the permission Page Public Content Access because I'm fetching images from my own account. This is also confirmed by the Facebook App Review support.
The query that is used to get the images is as follows:
https://graph.facebook.com/${pageId}?fields=id&access_token=${accessToken}
My access token in this case is app_id|app_secret since I can't access the user access token.
The developer api guide "https://developers.facebook.com/docs/instagram-api/getting-started/" only shows a way to get user access token using the client side Facebook SDK login button which generates a user access token after a visiting user interacts with a modal that pops up to have them login. But again, a simple Instagram image gallery shouldn't require every user that visit the site to log in to their own Facebook account.
I have bugged the App Review support team at Facebook with no real answer. I couldn't join the Facebook developers support group as no one is approving my request to join and I've also tried my best to seek help from the facebook developers support team but I can't reach them. So I'm turning to Stack Overflow to ask if there is any way to display images from an Instagram Business Account without sticking a Facebook login SDK modal on the site.
Thanks so much.
EDIT: After reading #misorude's comment, I'm thinking would adding the Facebook login modal on the website and querying it by logging into my own Facebook account and then capturing my own user access token that is returned by the api and then use that access token for every susequent api calls to fetch images work?

Can't get Instagram Business Account ID through Facebook Graph API

I'm trying to access the media of my Instagram business account through Facebook Graph API. I'm following this guide:
https://developers.facebook.com/docs/instagram-api/getting-started/
I've set up everything as requested: I have an Instagram business account, a Facebook page connected to this account and a Facebook app.
In step 5, when I try to get the Instagram Account ID with
GET /v3.0/{page id}?fields=instagram_business_account
the response I get looks different than the one in the guide. The Instagram business account field is missing, I only get back the ID of the Facebook page, which I already have.
Does anyone have an idea what could be wrong here?
Try the query below with the manage_pages permission.
/v3.0/me/accounts?fields=name,id,access_token,instagram_business_account{id,username,profile_picture_url}
I'm going through the review process and having trouble understand the permissions required to
Get Instagram Business Accounts
Subscribe to instagram_story_insights webhook
I only manage to get 1. by having the manage_pages permission. But I don't want to manage pages, just want to get the Instagram Business Accounts and request insights, feed and profile.
For 2. I only find the /subscribe endpoint and that requires a Facebook Page access token and that is only available with the manage_pages permission.
I was facing this issue since last 2 days and it was started suddenly.
I was able to resolve this issue by doing below steps.
Convert back your Instagram business account to personal account.
Now Convert your personal account to business account through the only facebook web not on instagram native app.
Important: We need to convert personal account to business account through the only facebook.
Hopefully you've figured this out by now. I had the exact same problem as you did where I would only get the id of my page.
The solution was adding the correct permissions to the user access token.
You will need to use a user access token with manage_pages and instagram_basic permissions when you make API calls to
GET /v3.0/{page id}?fields=instagram_business_account
We found that this happens for 2 reasons:
Instagram profile was not associated with Facebook page correctly (i.e. person converted did not have access to your page).
The person who converted Instagram to business and connected to the page is no longer an admin of the page
You connected your page and Instagram using Facebook page settings - that screen definitely does not work.
Make sure that your app has approved business_management permission and that you are asking for it when users authenticate facebook.
In all cases, converting instagram back to personal and then reconverting it to business fixes the issue.
Facebook Graph API 4.0 Only Supports Instagram Business Account. Creator instagram account doesn't work on graph api .
Check out below pics for getting instagram id from graph api
Click to View for Graph API Response
I was able to resolve this by going to the Facebook Page > Settings > Instagram and there I was prompted to "Review connection." I recently added the Instagram account "asset" to a user of our business account, so maybe that caused some need for the connection between the FB Page and IG account to be reviewed. I never received a notification from FB about this and I banged my head against the wall for over a day trying to debug this.
Given the Facebook account has a page (with {page id}) linked to the Instagram account. We managed to obtain ids via Browser (HTTPS Get) with
https://graph.facebook.com/v3.0/{page_id}?fields=instagram_business_account& access_token={Access token with the right permissions}
The token was manually generated using Facebook's Graph Explorer
https://developers.facebook.com/tools/explorer/v2/
Choose "User Token" option and Add the permissions "business_management", "manage_pages" and "instagram_basic" via the UI. Hit "Get Access Token" button to generate the token to be used with the "instagram_business_account" url query above.
To get images from the linked Facebook page, we currently do
https://graph.facebook.com/v3.0/{instagram_business_account}/media?fields=id,name,media_url,media_type,timestamp&access_token={Access token with the right permissions}
BTW, our Facebook account does have an app created under it so we could choose this app in the Facebook Graph API Explorer tool when the UI asked for it.
With the right permissions, one can covert these steps into code.
I am facing the same issue and I think thats because one of these two reasons:
the Graph API has updated its policy and requires all apps to undergo Business verification, which is part of the App Review process. Once your app gets verified then you can make those calls.
Your app is in live mode. Switch it off so it comes in development mode from your app dashboard. now you have access to all the api calls. Select the manage_pages and instagram_basic permissions from the graph api explorer. Now you can make the request.
I was facing same issue but i found the solution. At start be sure your instagram account should business account or Creator account.
And then link it with facebook from Facebook web.
Error only come when we use our personal account instead of Creator or Business.
This is my output now.
Add one more permission to your auth request: pages_read_engagement. No need to have manage_pages or public contents access to get Instagram ID.
I faced the same problem and I have resolved it. Follow the following steps to get the Instagram business ID.
(assuming that you already have an access token)
Step 1: Get the Facebook ID first [ GET v11.0/me?access_token={your_access_token} ]
{
"name": "your facebook page name",
"id": "facebook_page_id"
}
Step 2: Make sure that manage_pages , business_management and instagram_basic permissions are enabled. Can be easily done using Graph API Explorer.
Step 3: Using the Facebook ID we can obtain the Instagram business ID [ GET /v11.0/{facebook_page_id}?fields=instagram_business_account?access_token={your_access_token} ]
{
"instagram_business_account": {
"id": "insta_business_id"
}
}
Step 4: In case you are getting only Facebook ID after hitting the endpoint as mentioned in Step 3 then, using your mobile device switch back to your personal account. Again, enable the business account and make the HTTP request again. This method worked for me in getting the Instagram business id.
Finally solved it. Here is what I did to accomplish it.
I' not using business manager. The problem I was facing because my facebook account was not properly connected to instagram account. I thought I created instagram account with my facebook account so they were connected somehow. It was not the issues. Switching instagram account to business won't work. You need to connect your instagram account to your facebook business page.
Go to your pagee
Go to your page settings
Find instagram > you'll see connect. Here I had some problem connecting to instagram from here by logging in with facebook won't work. Do the traditional email password connection.
Last step if successfully connected it will ask you to switch your account. Click on button and done.
After an entire day searching the web (to no use) and reading Facebook/Instagram API docs (which is sometime misleading) I still could not successfully get the Instagram Business Account ID to make requests that use it, like the ig_hashtag_search request.
That's when I decided to ignore everything on the web, trust God, and start using Graph API Explorer's auto complete to try and make some sense of the whole thing!
It finally worked!
Before getting to the actual steps, make sure both Facebook and Instagram accounts are properly configured as business accounts! I don't know if it is a bug in the Brazilian version of Instagram's website, but the process to convert a regular Instagram account to a business account could only be completed using the native Instagram Android app. Specially the part where you link your Instagram account to a Facebook page that should already exist, and that should already have been created using Meta Business Suite.
Again, for me, as of today, the Public Business Information section was missing from the Brazilian version of Instagram's website!
After having configured and properly linked the accounts, it is possible to make the calls using Graph API v12.0.
Step 1
Access the Graph API Explorer.
Step 2
Add the following permissions:
ads_management
business_management
instagram_basic
public_profile
Step 3
Generate the Access Token using the button on the screen (in the popup, be sure to log in using a Facebook account that has both Facebook Business and Instagram Business accounts properly linked and configured).
Step 4
After obtaining the Access Token, get all Businesses IDs:
GET https://graph.facebook.com/v12.0/me/businesses?access_token=xxx
In the Graph API Explorer, you must type only this:
me/businesses
The response should be something like this:
{
"data": [
{
"id": "BUSINESS_ID",
"name": "Business Name"
}
],
...
}
Step 5
Use the BUSINESS_ID to finally get the Instagram Business Account ID:
GET https://graph.facebook.com/v12.0/BUSINESS_ID/instagram_business_accounts?access_token=xxx
In the Graph API Explorer, you must type only this:
BUSINESS_ID/instagram_business_accounts
The response should be something like this:
{
"data": [
{
"id": "INSTAGRAM_BUSINESS_ACCOUNT_ID"
}
],
...
}
And that's it!
If everything worked as expected, you can use this INSTAGRAM_BUSINESS_ACCOUNT_ID to make the desired requests, such as ig_hashtag_search or recent_media requests:
GET https://graph.facebook.com/v12.0/ig_hashtag_search?user_id=INSTAGRAM_BUSINESS_ACCOUNT_ID&q=DESIRED_HASHTAG&access_token=xxx
In the Graph API Explorer, you must type only this:
ig_hashtag_search?user_id=INSTAGRAM_BUSINESS_ACCOUNT_ID&q=DESIRED_HASHTAG
The response should be something like this:
{
"data": [
{
"id": "HASHTAG_ID"
}
]
}
Hope to have helped! 🙏

Instagram API Pulling Images Without Authorization Page

So I was going through Instagram's API and I implemented it. However it isn't as useful as I thought it would be because when trying to get and OAuth2 token a user is taken to a page to authorize them in what looks to be and effort of insuring that the user realizes that they are about to view and share Instagram content with my application. This all makes sense to me although not ideal. You can find it in detail here(Step One: Direct your user to our authorization URL).
Then I saw this press release from a company called Celtra who says they can pull the the most recent images off any Instagram feed and put them in an Ad. I checked it out and somehow they are pulling the images of other companies without this authorization page I am encountering. Basically without page scrapping I don't know how to do this with Instagrams API, and I realize scraping violates Instagrams terms of service. Does anyone have this functionality, where I can pull down images from Instagram and not take a user to an authentication page working legally as I am assuming Celtra is doing? Guidance or documentation on how to achieve this would be ideal.
Instagram recently added an endpoint that will allow you to any instagram account's photos without oauth or needing access_token, you can specify client_id and make API call to get photos.
Just register for an app account at here and add the client_id to this endpoint and make call:
https://api.instagram.com/v1/users/3/media/recent/?client_id=YOUR-CLIENT_ID
You only need access_token to get users' likes, follower feed and to like/comment/follow.
update: you need to have access_token with the new API changes, cannot
access API with just client_id anymore
To do this simply, you could authenticate your app from a dummy profile or your own personal profile and then use the access_token to request the feeds of any account. Then, when an end user goes to use your product, instead of authenticating them, you can just pull content from the Instagram API using your access_token.