With new facebook ads API. How do I find all the ad account ID's associated with a user?
I see all the documentation about how to get details about an Account (given id). But I can not find how to get a User's ad account id (via api) https://developers.facebook.com/docs/marketing-api/adaccount/v2.3
Please advise.
This has helped me and I hope will help someone else too one day.
These are the steps to achieve campaign list after oAuth.
Step 1 (Front-end):
Do authentication frontend side with following URL:
https://www.facebook.com/v3.0/dialog/oauth?client_id=<client_id>&redirect_uri=<URL>&scope=email%2Cads_management%2Cads_read&response_type=code&state=<state>
Step 2 (Front-end + Backend):
Step 1
will give code
object, pass it to backend
Step 3 (Backend):
Fetch access-token
of user using following API
https://graph.facebook.com/v10.0/oauth/access_token?client_id=<client_id>&redirect_uri=<redirect_URL>&client_secret=<client_secret>&code=<code-from-front-end>
Step 4 (Backend):
Fetch Ads account details:
https://graph.facebook.com/v10.0/me/adaccounts?access_token=<access_token_from_step_3>
Step 5 (Backend):
Fetch Campaigns list:
https://graph.facebook.com/v10.0/act_<account_id_from_step_4>/campaigns?access_token=<access_token>&fields=id,name,objective,configured_status,effective_status,account_id,bid_amount,bid_strategy,start_time,end_time,targeting,daily_budget,campaign_id,special_ad_categories
Here you will get Campaign list of authorized user.
Note:
Admin/Developer/Tester
listHit the /me/adaccounts path to retrieve accounts your access token (and app) can read.
See the Edges section of the user Graph API documentation for the adaccounts edge: https://developers.facebook.com/docs/graph-api/reference/user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With