Instagram Graph API - Use Business Discovery and Insights edge combined - facebook-graph-api

I am able to fetch the list of media objects associated with an external user using the following URL
GET (my IG user id)?fields=business_discovery.username(therock){media{caption,children,comments_count,like_count,id,media_type,media_url,owner,timestamp,username}}
How do I fetch the Insights of an external user using the above method. I do know to fetch the insights of my own account using the following URL
GET (my IG user id)/insights?metric=impressions&period=week
When I try to fetch the insights using the URL below
GET (my IG user id)?fields=business_discovery.username(therock){insights}}
the following error is thrown
{
"error": {
"message": "Syntax error \"Expected end of string instead of \"}\".\" at character 46: business_discovery.username(therock){insights}}",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "FeWhDF4hOJY"
}
}
Is it possible to fetch the insights of an external account?

To retrieve insights from a FB page you have to provide credentials from one of the page admins. If you have them, you don't need to use the business_discovery endpoint. If you don't have them, you cannot retrieve insights.

GET (my IG user id)?fields=business_discovery.username(therock){insights}}
Looks like you simply left an extra } there at the end - remove the superfluous one, then the error should be gone.
(With {media{...}} you had two levels of nesting, but now you have only one.)

Related

What permissions are needed to call /{page-id}/ads_posts on Facebook Graph API?

I'm trying to list the Ads for a Facebook Page using the Graph API /{page-id}/ads_posts endpoint, but I get a permissions when I try to.
Using the Graph API Explorer, I generate an Page Access Token with those permissions: email, read_insights, manages_pages, pages_show_list, ads_read, business_management, instagram_basic, instagram_manage_insights and public_profile.
I'm an admin on the Page itself, the attached Business Manager and on the corresponding Ad Account.
Every time I try to call the /{page-id}/ads_posts, I receive
{
"error": {
"message": "(#200) Not enough permission to call this endpoint",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "XXXXX"
}
}
I can't find any help on the Facebook documentation or Google, given that the error isn't really meaningful (in some cases, I get a message saying that a specific permissions is missing, but not here). Anyone can help ?
EDIT: I tried to add the ads_management permission too, without success.
You need to add those pages to your app that is in development mode (https://www.facebook.com/settings?tab=business_tools).

Can we make changes in the IAM policies of google by using some other's access/bearer token

I am working on the GmailwebhookTrigger in which I am getting the notification for the new emails. I want to add multiple members into my topic means want to get notifications for multiple people on my topic. To do that I have to add that member as pub/sub subscriber into my iampolicy console. I am not able to do that it is giving me following error
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
by hitting the following api
https://cloudresourcemanager.googleapis.com/v1/projects/gmailwebhookserver:getIamPolicy
also if I tried to hit the following other api I get the same error
https://cloudresourcemanager.googleapis.com/v1/projects/gmailwebhookserver:setIamPolicy
I have done everything provided in the documentation to fix that, but I am not able to do so. But when I am adding external user as owner to project in my IamConsole at following url https://console.cloud.google.com/iam-admin/ia?project=testProject, I am able to achieve what I am willing to achieve. But that thing I have to do manually by doing so I am giving full rights of my project to other users. I think to allow external users to make changes in my cloud iampolicies I need to authenticate external users using my service account. But I don't know how to do that. Suggest me way either to authenticate user with my service account or by any other means, so that I may have to do nothing manually.

Unable to retrieve data from facebook graph url for a page

Check out:
https://www.facebook.com/MitraJyothiorg
It is a page of an NGO.
Correspondingly, I should be able to find data of the page in:
http://graph.facebook.com/MitraJyothiorg
This does not seem to work. Any clues?
Please note: I am doing a simple http call and it usually works for other pages, for example, if i do the same thing for another page:teachforindia
The error message is quite clear:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
You need to add at least an App Access Token. See
https://developers.facebook.com/docs/graph-api/reference/page#Reading
For pages that are published, you need:
An app or user access token is needed to view fields from fully public pages.
A user access token is needed to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.
I am not able to access that page (get a 404 error). Maybe the page is still hidden? Then you will not be able to access it via the graph API imho.

Facebook Reach Estimate - not suficient permissions

I am trying to follow an example on Reach Estimate in facebook API documentation here. However I am getting an error:
{
"error": {
"message": "(#10) You do not have sufficient permissions to perform this action",
"type": "OAuthException",
"code": 10
}
}
My approach is to open https://developers.facebook.com/tools/explorer, generate a token giving all permissions including ads_management.
And perform call:
act_ID/reachestimate?currency=EUR&targeting_spec={'countries':['US']}
Where I obtain ad account ID by going to my ads manager and reading it off URL (or by visiting power editor).
It looks simple, but I have no idea at this point what I am missing, I am also getting the same error while using PHP API.
All ideas are much appreciated. Thank you.
If you are using your own app to generate the access token, you are likely on the Standard or Basic tier of the Marketing API. For these tiers, you need to specify each AdAccount you are going to use.
In the developer too, select your app and go to Apps > Settings > Advanced. Under "Advertising Accounts" click the "Ads API" button on the right hand side, and list all the accounts you want to use.
For more info, see:
https://developers.facebook.com/docs/marketing-api/access#standard_accounts

Facebook ad account group API access not correct on Facebook's site

I'm trying to build an application that will help manage different ad accounts for different customers (multiple businesses, so it has to handle multiple ad accounts). I'm looking at the ads API documentation for ad account groups, and the examples aren't working in the graph API explorer. Things like GET requests to
https://graph.facebook.com/v2.4/<AD_ACCOUNT_GROUP_ID>/users
(from Facebook's documentation here) are returning the following error:
{
"error": {
"message": "(#275) Ad account cannot be determined for this request",
"type": "OAuthException",
"code": 275
}
}
As best as I can tell, the documentation is incorrect - I think it can't tell the difference between an ad account ID and an ad group ID (I know this pattern is also used for things like managing custom audiences which is why I'm guessing it thinks it should be seeing an add account ID). Is there a better guide on updating ad account group membership via the API I can reference, or an endpoint I can substitute in for Facebook's official documentation?
First off please note at this time, you can still use v2.3 Facebook graph calls, prior versions have been deprecated by Facebook.
You will get this error. If you try older graph versions:
{
"error": {
"message": "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version.",
"type": "OAuthException",
"code": 2635
}
}
At the time of this writing you can use v2.3 calls and it still works.
Next I presume you want to know all the users, within accounts so the first thing to do is to get the list of accounts... Then iterate through each.. on an ad account basis.
Look up the api call to get a list of ad accounts, for a Facebook user id.
You will need the ad_read permission on the token in order to get the list.
Your api call should then look like this to get the users on each account.
Notice I put act_ in front of the actual account id. This is required and tells Facebook you are dealing with an ad account.
https://graph.facebook.com/v2.3/act_999998730499999/users?access_token=CAZZZZZpCZBjEBAJmcyfqbcluGAJZCtqfv4kI6CtLC7JGHaJ7IO2ImGCfkQFZC9NXCAZC2CAbtEdQcWMYFpqsFAkgJVqNqjnKGQkMrukyl53WZBIdq7vofFYyxvaTJTsWVOQhWTrjNoox0QqRCt3vGaDsRGHLBFDxqKLfXOcDKfS1oppj1nDjKdPe2GHYrHirlBkhxWS95MNgW7ajZZZZZ
Note: I have added ZZZZZs and 9999s in places to disguise my actual account and token.
The token used must be the ad account holder's token for the app. The user must have authorized the app for the ad_read permission on this token creation for the call to work.
The result looks like this:
{
"data": [
{
"name": "Joe Programmer",
"permissions": [
1,
2,
3,
4,
5,
7
],
"role": 1001,
"id": "999995304499999"
}
]
}
When using the development access of the Facebook Ads API, you need to specify which adaccounts you are going to use and you must own the adaccounts.
See the following guide:
https://developers.facebook.com/docs/reference/ads-api/access#standard_accounts