I want to get Leadinfo from my Lead ads using python and the facebook API.
I have tried this:
import json from facebook_business.api import FacebookAdsApi from facebook_business.adobjects.adaccount import AdAccount from facebook_business.adobjects.leadgenform import LeadgenForm from facebook_business.adobjects.lead import Lead access_token = '<my_token>' ad_account_id = 'act_my_ad_acount' FacebookAdsApi.init(access_token=access_token) ad_account = AdAccount(ad_account_id) ads = ad_account.get_ads(fields=[ Ad.Field.id, Ad.Field.name, ]) leads = [] for ad in ads: lead = ad.get_leads(fields=[ Lead.Field.id, Lead.Field.field_data ]) leads.extend(lead) print(leads)
However it breaks due to this error:
There have been too many calls from this ad-account. Please wait a bit and try again.
I understand that I should be doing some kind of batch call. But I found the documentation too hard do understand. It took me three days just get the code to list the ads in my account.
Could someone, please help me?
My end goal is to retrieve the information that the users sent on the leadforms ads, ei. their name, telephone, etc..