Currently my fb app has only developer level access.
Is it possible to get data from a marketing account which is connected with nameX fb account from my fb app which is connected with nameY fb account?
I've tried to do an API call 'act_' about such marketing account, but all I've got is:
{
"error": {
"message": "(#10) You do not have sufficient permissions to perform this action",
"type": "OAuthException",
"code": 10
}
}
I know obviously about a business marketing platform where you can create a few marketing accounts, but I'm looking for smth more.
Currently 2 marketing accounts are connected to my fb app. The calls to the one which is on the same fb account as the app work.
BTW, My is on the fb business marketing platform.
I think your app is on development-tier of marketing api app - that's why it has limited number of accessible adaccounts. You could go to developer dashboard (https://developers.facebook.com/apps/APP_ID/review-status/) to apply for business management permission, and then you're good to go.
Related
I have an Angular 5 app where I need to grab some data from my ad accounts via a Business Manager account that I have been made an admin of. I'm having trouble figuring out which API documentation I need to follow and which endpoints to call.
I'm just trying to figure out how to get data from the Graph API Explorer that Facebook provides and when I try something like this:
/v2.12/<business-account-id>/adaccounts I get an error:
{
"error": {
"message": "(#12) adaccounts field is deprecated for versions v2.11 and higher",
"type": "OAuthException",
"code": 12,
"fbtrace_id": "AV2JHORP+bN"
}
}
I have all the correct permissions set with my access token, though I'm not sure what to call to get that data. There are a lot of different API docs and I'm not sure which ones to follow.
Has anyone run into this as well?
I recently wrote a blog post explaining in-depth how to do this, and here is a brief overview:
Ad Accounts Owned by Your Business
To get the list of ad accounts that your Business account owns, you can make a call to the following URL:
/<API_VERSION>/<BUSINESS_ID>/owned_ad_accounts
Read more at: https://developers.facebook.com/docs/marketing-api/businessmanager/assets
Ad Accounts Owned by Your Clients
You can pull all ad accounts owned by other Business accounts by using the client_ad_accounts edge:
/<API_VERSION>/<BUSINESS_ID>/client_ad_accounts?fields=id,name,business
Requesting the business field will give you information about the Business that is sharing the ad account to you.
(Thanks to user skinnyas123 for reminding me about the new edge to get clients' ad accounts! I began using it awhile back and forgot to update this answer.)
We have a company-owned web application that should post to our company-owned facebook page.
should be a server-to-server call
the user in our webapplication who makes the post in the webapplication gui, should ideally not have to be a facebook admin for the facebook page.
We have a facebook App that is added to a testpage on facebook, and when I do this API call:
https://graph.facebook.com/PAGE-ID/feed?message=MESSAGE-CONTENT&access_token=APP-ID|APP-SECRET
..the answer I get back is:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "TRACE-ID"
}
}
It seems like I need the publish_pages right, and this right require an App-review (unless users are known and assigned roles in the app), but it says in the review info from facebook, that automatically publishing is not allowed for this right.
We can save a token in database and reuse when posting to Facebook Graph API.
Is this impossible without a facebook user doing a Facebook login in our webapplication?
Should we instead get a long-lived user token from a facebook-page-administrator, and then reuse this when posting, and re-login to facebook client side, before token expire?
I want automatically collect data from fb ad account with marketing api.
There is an facebook app, which has access to advertising account (with access level = development). App has product 'Marketing API'.
Got access_token (app_id|token) like this:
GET https://graph.facebook.com/oauth/access_token?client_id=<app_id>&client_secret=<secret>7&grant_type=client_credentials
When i try insights method
GET https://graph.facebook.com/v2.8/act_<ad_account_id>/insights/?access_token=<access_token>
i got an error
"message": "Unsupported get request.", "type": "GraphMethodException", "code": 100
Try to generate not app token, but user token of someone who has access to that ad account.
I need to access Facebook API to retrieve ads stats. All my requests will be handled on server side. I already know how to access those data by obtaining User Access Token with ads_read permission, where user has admin role in the ad account.
My application will use cron jobs to retrieve ads stats, so I would like to use App Access Token instead, because user won't need to authenticate with the dialog, right? I assigned application to the business, but it doesn't seem to work. After trying to get ads stats with App Access Token, I'm getting following error:
{
"error": {
"message": "The entity backed by id 1234567890123 cannot be seen
by the viewer with (ViewerID 0, AccountID 0):
DENY_RULE:InlinePrivacyPolicy:AlwaysDenyRule:4
(EntID: 1234567890123)",
"type": "OAuthException",
"code": 1
}
}
The application is assigned to the business, but I'm not sure if it's enough. I don't see any option to assign it to the ads account.
Am I doing it right or maybe there's another way to skip dialog part?
No, you need to use a user access token from a user who manages the ad account.
App access tokens are only useful for a narrow range of use cases, primarily for updating app settings or proving a call came from the app specifically, rather than an arbitrary user of the app
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