I am getting the following error from the below code and I can’t seem to work out what exactly i am not doing right, I feel as though I am specifying the correct account IDs but it isn’t being accepted.
import hashlib
import hmac
import sys
sys.path.append('./.venv/lib/python3.12/site-packages') # Replace this with the place you installed facebookads using pip
sys.path.append('./.venv/lib/python3.12/site-packages/facebook_business-3.0.0-py2.7.egg-info') # same as above
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
my_app_id = '995427558947840'
my_app_secret = '04765ed9281612e2aa8723935a7e4ad2'
my_access_token = 'EAAVuWk8drdWkBOw5gCusNtZCxbwej5AIQdBsVhug4SZCneZCU95y2LgIyd5ulE8JC2KMfoyVYdxF5CZBrvyZCp6vYJzhApftZBp9Y4Lt0TtkRcOsTJmOE2AZBGbrbJcpn6ZAqXzyqTloLqrFSohRb6gBTz5KVI1m0VU7qLTCuZBMvNlTZBw5CiwbBQZBLGYh98rht0q3N7gPdJgunZCrVZAjWFeZCsYc2ZCvRCAZD'
app_secretproof = hmac.new(bytes(my_access_token,'utf-8'),bytes(my_app_secret,'utf-8'),hashlib.sha256 ).hexdigest()
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token, app_secretproof)
account = AdAccount('act_229199089180260')
campaigns = account.get_campaigns()
print(campaigns)
Account ID provided in FacebookAdsApi.set_default_account_id expects a string that begins with ‘act_’
I expect this code to bring me back all the campaigns in my given Facebook Ad account
New contributor
RFL3TCH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.