from facebookads.api import FacebookAdsApi from facebookads.objects import AdAccount FacebookAdsApi.init(access_token='your_access_token_here') me = AdUser(fbid='me') my_accounts = me.get_ad_accounts() for account in my_accounts: print(account)
from facebookads.api import FacebookAdsApi from facebookads.objects import AdCampaign, CampaignObjective FacebookAdsApi.init(access_token='your_access_token_here') campaign = AdCampaign(parent_id='act_your_account_id_here') campaign[Campaign.Field.name] = 'My New Campaign' campaign[Campaign.Field.objective] = CampaignObjective.link_clicks campaign.remote_create()This code initializes the FacebookAdsApi with the access token, creates a new AdCampaign object for the specified account, sets the name and objective fields, and then creates the campaign remotely using the API. Package Library: The FacebookAdsApi and AdAccount and AdCampaign objects are part of the Facebook Ads API Python SDK, which is available for download from the Python Package Index.