Instagram Graph API - facebook-graph-api

My task is to get photo data of my business Instagram account with Instagram Graph API. I followed the instruction from Instagram Graph API -
https://developers.facebook.com/docs/instagram-api/reference/user/media
, which said request like
GET http://graph.facebook.com/17841405822304914/media
can get photo data from the Instagram account linked to the FB account in JSON format.
I tried to send GET request /my_facebook_id/media as said by the document with Graph API Explorer on FB developer platform but it failed to return the data I want.
This is the error I got:
message: Tried accessing nonexisting field (media) on node type (User)
type: OAuthException code: 100
Does the message mean the media field doesn't exist in the FB user?
What is the meanIng of error code 100? I can't even see that in FB official document.
I tried to use the Instagram business account ID for this request but I got an error message said the user object doesn't exist
How to get the task done? Thanks!

I guess you have missed creating a Facebook business page and linking your Instagram Business account to it.
Here is the guide to setup : https://developers.facebook.com/docs/instagram-api/getting-started
If this was done correctly and still you're facing the error is because of a Facebook bug where your account doesn't get linked correctly.
Here : https://developers.facebook.com/support/bugs/177912116363088/?disable_redirect=0
Solution : Please disconnect your Instagram account from your page. Then, on Instagram app, in setting you will have to switch back to personal account and reconvert to a business account
Note : Switching to a personal account you will lose the insights of your media.
Once this is done you should be able to get instagram_business_account and post which you can run your query to fetch the media :
GET http://graph.facebook.com/you-instagram-business-account-id/media

Related

How to get a valid access token to query search result from Facebook graph API

I want to collect all the Facebook link from Facebook search function. What I'm using here is the Facebook graph API tool.
If I want to query the data for a keyword, for example: "limited";
I will use the URL:
https://graph.facebook.com/v11.0/search?q=limited&access_token={my_access_token}
My image
However, I got the result as in the image. When I tried to create a workplace app and tried to get the access token of that app, I got the message as in the second image.
Error message when getting the access token of a workplace app
What I need now is an access token that has the permission to retrieve the data from the Facebook search. After that, I can use python to handle the rest.
Please help me out, thank you very much!

Fb/Instagram Graph API: (#10) permission denied on business_discovery

I'm trying to run the following:
<my_insta_fbid>?fields=business_discovery.username(<business_page>)
on https://developers.facebook.com/tools/explorer
But I'm getting an error (#10) permission denied
My app is approved for instagram_basic, User Token also includes it
Business verification is passed too
I have Instagram Graph API and Instagram Basic Display products included
Instagram account is connected to my fb that generates user token(but created separately)
Insta account I use is included into Instagram Basic Display
Of course, I use and request instagram business accounts
I tried both Live and Development app modes
All the other requests related to <my_insta_fbid> like name or biography work. The only that fails is business_discovery
What else am I missing?
I found it!
My tests have shown that I was missing the instagram_manage_insights permission.
I didn't find any mentions of this in the documentation but it worked in my case

Facebook API - How to add a new Admin to a facebook Page using graph API?

I am trying to add a new Admin (facebook user) to a facebook Page using Graph API as shown in the screenshot but i get an error message:
"(#200) Either app or user doesn't have permission to modify admins."
When i check the access_token permissions it looks like i have everything in scope and still the request fails. Anyone has encountered this before?
Please check the attached screenshots.
Graph API request
Page AccessToken permissions

Facebook Graph API return error when call Business Discovery API

When I call the api:
graph.facebook.com/userid?fields=business_discovery.username(name){followers_count,media_count}
in Graph API explore, I got an invalid parameter error:
(#100) Tried accessing nonexisting field (business_discovery) on node type (User)
Could anyone please explain to me what I miss in the API url?
Thanks
This only works for Instagram Business Accounts, but you seem to be using it with a normal user id.
As https://developers.facebook.com/docs/instagram-api/reference/user/business_discovery says,
Instagram Platform API account IDs will not work with the new Instagram Graph API. Please use the Page node to determine the correct Instagram Business Account ID associated with the Facebook page.
You can not use this for other types of Instagram accounts, only for business accounts.
In my case the problem was that the instagram account was not connected to the page when the access-token was issue i.e. I added the instagram account after connecting the app.
So what worked for me was to remove the app, make sure that the instagram account is connected to the page the connect the app. Now the access token works.

Graph API: All Mutual Friends Returning Empty List

All mutual friends request made from my app server (node) (also tried the Facebook API explorer) suddenly started returning an empty array for the data field. I confirmed and validated my access token and appsecret_proof on the API explorer. Do you know what has changed or what the request below is missing?
Note: both users use the app and have granted user_friends permission.
I am using v2.12
request
{
url: 'https://graph.facebook.com/v2.12/{user-facebookid}?fields=context.fields(all_mutual_friends.limit(5000))',
qs: {access_token: 'XXXXX'
,
appsecret_proof: crypto.createHmac('sha256', clientSecret).update(accessToken).digest('hex')
}
Yep. Facebook has taken down the Graph API for page access tokens. The only way to retrieve data (or was a week or so ago), was a temporary user token that lasts about 2 hours. It's totally broken my band's schedule page. I've been through every avenue and even spoke with a facebook ad team employee on the phone that was aware of it. She seemed to empathize but had no solution for me. I would count on it being down for a while.
I have finally figured out a work around for this. On your fb application, you have to disable the secret key requirement. This can be found under the advance settings of your fb application console. It's called "
Require App Secret".
Once you generate a fb PAGE access token, you get a fb page token, and then extend it.
here is the token debugger:
https://developers.facebook.com/tools/explorer/
You can extend the access token programmatically as explained here:
https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension
AND
https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens
There is also an extend tool in the access token debugger.