Example #1
0
def create_campaign(name):
    try:
        FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
        my_account = AdAccount(f'act_{ad_account}')

        fields = []
        params = {
            'name': name,
            'objective': 'VIDEO_VIEWS',
            'status': 'PAUSED',
        }
        return my_account.create_campaign(
            fields=fields,
            params=params,
        )
    except Exception as e:
        print(type(e))
Example #2
0
def createCampaign(my_app_id, my_app_secret, account_id, my_access_token):
    FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
    fields = []
    account = AdAccount(account_id)
    campaign = account.create_campaign(fields=fields,
                                       params={
                                           'name': 'Lets Talk Openly',
                                           'buying_type': 'AUCTION',
                                           'objective': 'LINK_CLICKS',
                                           'status': 'PAUSED',
                                           'special_ad_categories': 'None',
                                           'targeting': {
                                               'age_min': 20,
                                               'age_max': 35,
                                               'genders': [1],
                                               'geo_locations': {
                                                   'countries': ['US']
                                               }
                                           }
                                       })

    print('campaign', campaign)
Example #3
0
def create_campaign(app_id: str, app_secret: str, account_access_token: str, account_id: str, fields, params):
    FacebookAdsApi.init(app_id, app_secret, account_access_token)
    account = AdAccount(account_id)
    return account.create_campaign(fields=fields, params=params)
Example #4
0
my_app_id = '2317550648481540'
my_app_secret = '4c1c34b9502793e4837a00f2a7b7f7aa'
page_id = '601550560344776'
my_access_token = 'EAAg7zM8m1wQBAO1qB31k7nrE3YpKZBuzobZA8ebzC2JNriCF5uKK6P8R6zc268N4CnZAdjHF88gUZCRLIyRwEqDZCAWA3GQw5Q8p0eQ4TpliBEsfZBZB1GLDpfXkSnDKZAYYiDXgZACp4IdrK6ZAUl9ieAyCM35pScFJEliEYiH8Q3oSKLqkkIPN1MVB7UE6RoLK8ZD'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
my_account = AdAccount('act_306011116959172')

fields = []
params = {
    'objective': 'PAGE_LIKES',
    'status': 'PAUSED',
    'buying_type': 'AUCTION',
    'name': 'My Campaign',
}
campaign = my_account.create_campaign(
    fields=fields,
    params=params,
)
print('campaign', campaign)

campaign_id = campaign.get_id()
print('campaign_id:', campaign_id, '\n')

fields = []
params = {
    'status': 'PAUSED',
    'targeting': {
        'geo_locations': {
            'countries': ['US']
        }
    },
    'daily_budget': '1000',