Reputation: 757
Am trying to get a list of ad accounts in my business manager in the form of:
<Ad Account id; Ad Account name>
This is how a get the list of ad accounts:
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
me = AdUser(fbid='me')
my_account_first=me.get_ad_accounts()[0]
>>>print my_account_first
<AdAccount> {
"account_id": "1654219XXXXXXX",
"id":
type(my_account_first)
<class 'facebookads.objects.AdAccount'>
Here is the class definition: https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/objects.py#L964
Could anyone advise how to extract FB Ad account name once I have the account ID? It seems like an obvious task, but can not find the respective API method/field.
Thank You in adavance for any guidance.
Upvotes: 3
Views: 3510
Reputation: 883
You can specify which fields are present in the response, by setting the fields
parameter in the get_ad_accounts
call.
my_account_first=me.get_ad_accounts(fields=[AdAccount.Field.name])[0]
The SDK repo has a lot of good examples for different use cases: https://github.com/facebook/facebook-python-ads-sdk/tree/master/examples
Upvotes: 3