Reputation: 179
I am using python Facebook Ads SDK, I try to get my ad accounts:
from facebookads import FacebookAdsApi
from facebookads import objects
my_app_id = 'my_app_id'
my_app_secret = 'my_app_secret'
my_access_token = 'my_access_token'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
me = objects.AdUser(fbid='me')
my_accounts = list(me.get_ad_accounts())
print my_accounts
but when I run the script I got ImportError: cannot import name objects
Upvotes: 0
Views: 2431
Reputation: 561
Since Facebook deprecated v2.8 a few days ago, some might be affected by this. Try this revised code.
from facebookads import FacebookAdsApi
from facebookads.adobjects.user import User
my_app_id = 'my_app_id'
my_app_secret = 'my_app_secret'
my_access_token = 'my_access_token'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
me = User(fbid='me')
my_accounts = list(me.get_ad_accounts())
print my_accounts
Best of luck
Upvotes: 1
Reputation: 71
All the facebook ads objects that you need to import are under AdObjects starting v2.7 for PHP and Python ads sdks.
Upvotes: 0
Reputation: 3
Are you using 2.9.1 version of the facebook marketing API? if yes - there is no object to import in this version. is was there till v2.8.1
Upvotes: 0