I have installed facebook_business with pip:
pip install facebook_business
I believe my credentials are correct because I can print the list of campaigns id like this:
import sys
sys.path.append('C:/users/user/anaconda3/lib/site-packages')
sys.path.append('C:/users/user/anaconda3/lib/site-packages/facebook_business-8.0.2-py3.7.egg/')
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
my_app_id = 'XXX'
my_app_secret = 'XXX'
my_access_token = 'XXX'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
my_account = AdAccount('act_XXX')
campaigns = my_account.get_campaigns()
print(campaigns)
result:
[<Campaign> {"id": "xxx"}, <Campaign> {"id": "xxx"}]
However when trying to use adobjects, for example:
my_account = adobjects.AdAccount('act_xxx')
I get this error:
NameError: name 'adobjects' is not defined
I imported like this and it works now: