What is the best and most optimal way to check the list of given ad_groups (list of ad_group ids) for disapprove status and to get the reasons of disapprovements?
The most straight-forward but not optimal way is to:
1) Get all disapproved ad_groups of the account:
params = {
'status': ['DISAPPROVED'],
'limit': 1000
}
adgroup_iter = account.get_ad_groups(params=params)
disapproved_ad_ids = []
for adgroup in adgroup_iter:
disapproved_ad_ids.append(adgroup._data['id'])
2) From resulting list select only the ad_groups of interest by intersecting lists:
ads_of_interest = list(set(ad_ids_to_check) & set(disapproved_ad_ids))
3) Make a request FOR EACH ad_group of interest for it's disapprovement reasons (adgroup_review_feedback field):
for adgroup_id in ads_of_interest:
adgroup = AdGroup(adgroup_id)
print adgroup.remote_read(fields=[AdGroup.Field.adgroup_review_feedback])
The bad thing that I have a lot of ads running and it's not good to make a separate API call to get disapprovement reason for each of them because it just makes me to exceed the facebook requests limit.
ENDED UP WITH THE SOLUTION:
params = {
'adgroup_status': ['DISAPPROVED'],
'limit': 500,
'fields': 'id,adgroup_review_feedback'
}
and then looking up for the intersections of results and the list of 'interesting' ads discarding the 3rd paragraph of my question because the needed data already is contained in results from 1st (thanks for @Igy answer)
Mention the 'adgroup_status'
field name instead of 'status'
(as given in my question) - this solved the problem of the wrong facebook responses. Probably it is the typo in documentation in "Fetching all ads of ad ad account..." example for Python SDK as it's not working in SDK v.2.2.6