当前位置: 首页>>代码示例>>Python>>正文


Python AdSet.remote_create方法代码示例

本文整理汇总了Python中facebookads.objects.AdSet.remote_create方法的典型用法代码示例。如果您正苦于以下问题:Python AdSet.remote_create方法的具体用法?Python AdSet.remote_create怎么用?Python AdSet.remote_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在facebookads.objects.AdSet的用法示例。


在下文中一共展示了AdSet.remote_create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_adset

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
def create_adset(campaign_id):
    adset = AdSet(parent_id='act_259842962')
    adset.update({
        AdSet.Field.name: 'My Ad Set',
        AdSet.Field.campaign_id: campaign_id,
        AdSet.Field.daily_budget: 10000,
        AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
        AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
        AdSet.Field.bid_amount: 2,
        AdSet.Field.targeting: {
            Targeting.Field.geo_locations: {
                'countries': ['IN'],
            },
            Targeting.Field.age_min: 20,
            Targeting.Field.age_max: 24
        },
        AdSet.Field.status: AdSet.Status.paused,
    })
    adset.remote_create()
    return adset
开发者ID:govind1246,项目名称:python-flask-dokku-app,代码行数:22,代码来源:sample_main.py

示例2: create_ad_set

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
 def create_ad_set(self, account_id, name, daily_budget, campaign_id,
                   optimization_goal, billing_event, bid_amount,
                   targeting, app_id, app_store_link):
     """
     create an ad set in campaign we just created.
     """
     pdata = {
         AdSet.Field.name: name,
         AdSet.Field.optimization_goal: optimization_goal,
         AdSet.Field.billing_event: billing_event,
         AdSet.Field.bid_amount: bid_amount,
         AdSet.Field.daily_budget: daily_budget,
         AdSet.Field.campaign_id: campaign_id,
         AdSet.Field.promoted_object: {
             'application_id': app_id,
             'object_store_url': app_store_link
         },
         AdSet.Field.targeting: targeting,
     }
     pdata['status'] = AdSet.Status.paused
     adset = AdSet(parent_id=account_id)
     adset.remote_create(params=pdata)
     return adset[AdSet.Field.id]
开发者ID:adi69,项目名称:automated-f-ads,代码行数:25,代码来源:app_install_ad_sample.py

示例3: create_adset

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
def create_adset(campaign=None, params={}):
    if campaign is None:
        campaign = create_campaign()

    adset = AdSet(parent_id=test_config.account_id)
    adset[AdSet.Field.name] = unique_name('Test Adset')
    adset[AdSet.Field.campaign_id] = campaign.get_id()
    adset[AdSet.Field.targeting] = {
        'geo_locations': {
            'countries': ['US'],
        },
    }
    adset[AdSet.Field.optimization_goal] = AdSet.OptimizationGoal.impressions
    adset[AdSet.Field.billing_event] = AdSet.BillingEvent.impressions
    adset[AdSet.Field.bid_amount] = 100
    adset[AdSet.Field.daily_budget] = 1000

    adset.update(params)
    adset.remote_create()

    atexit.register(remote_delete, adset)

    return adset
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:25,代码来源:fixtures.py

示例4:

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
                    },
                },
            ],
        },
    ],
    TargetingSpecsField.excluded_product_audience_specs: [
        {
            'product_set_id': product_set_id,
            'inclusions': [
                {
                    'retention_seconds': 259200,
                    'rule': {
                        'event': {
                            'eq': 'ViewContent',
                        },
                    },
                },
            ],
        },
    ],
}
adset[AdSet.Field.promoted_object] = {
    'product_set_id': product_set_id,
}
adset[AdSet.Field.product_ad_behavior] = 'FALL_BACK_TO_FB_RECOMMENDATIONS'

adset.remote_create()
# _DOC close [ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION]

adset.remote_delete()
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION.py

示例5: AdSet

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
# _DOC open [ADSET_CREATE_DYNAMIC_PROSPECTIING]
# _DOC vars [ad_account_id:s, product_set_id, campaign_id]
from facebookads.objects import AdSet, TargetingSpecsField

adset = AdSet(parent_id=ad_account_id)
adset[AdSet.Field.name] = 'Case 1 Adset'
adset[AdSet.Field.bid_amount] = 3000
adset[AdSet.Field.billing_event] = AdSet.BillingEvent.link_clicks
adset[AdSet.Field.optimization_goal] = AdSet.OptimizationGoal.link_clicks
adset[AdSet.Field.daily_budget] = 15000
adset[AdSet.Field.campaign_id] = campaign_id
adset[AdSet.Field.targeting] = {
    TargetingSpecsField.geo_locations: {
        TargetingSpecsField.countries: ['US'],
    },
    TargetingSpecsField.interests: [{
        'id': 6003397425735,
        'name': 'Tennis',
    }],
}
adset[AdSet.Field.promoted_object] = {'product_set_id': product_set_id}
behavior = 'FALL_BACK_TO_FB_RECOMMENDATIONS'
adset[AdSet.Field.product_ad_behavior] = behavior

adset.remote_create(params={
    'status': AdSet.Status.paused,
})
# _DOC close [ADSET_CREATE_DYNAMIC_PROSPECTIING]

adset.remote_delete()
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:ADSET_CREATE_DYNAMIC_PROSPECTIING.py

示例6: AdSet

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
from examples.docs import fixtures
from facebookads import test_config

ad_account_id = test_config.account_id
pixel_id = fixtures.create_ads_pixel().get_id()
campaign_id = fixtures.create_campaign().get_id_assured()

# _DOC open [ADSET_CREATE_CONVERSIONS_PURCHASE]
# _DOC vars [ad_account_id:s, campaign_id, pixel_id]
from facebookads.objects import AdSet, TargetingSpecsField

adset = AdSet(parent_id=ad_account_id)
adset.update(
    {
        AdSet.Field.name: "Ad Set oCPM",
        AdSet.Field.bid_amount: 150,
        AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
        AdSet.Field.optimization_goal: AdSet.OptimizationGoal.offsite_conversions,
        AdSet.Field.promoted_object: {"pixel_id": pixel_id, "custom_event_type": "PURCHASE"},
        AdSet.Field.daily_budget: 1000,
        AdSet.Field.campaign_id: campaign_id,
        AdSet.Field.targeting: {TargetingSpecsField.geo_locations: {"countries": ["US"]}},
    }
)

adset.remote_create(params={"status": AdSet.Status.paused})
print(adset)
# _DOC close [ADSET_CREATE_CONVERSIONS_PURCHASE]

adset.remote_delete()
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:ADSET_CREATE_CONVERSIONS_PURCHASE.py

示例7:

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.bid_amount: 150,
    AdSet.Field.daily_budget: 2000,
    AdSet.Field.campaign_id: campaign_id,
    AdSet.Field.targeting: {
        'geo_locations': {
            'countries': ['US'],
        },
        'interests': [
            {
                'id': 6003139266461,
                'name': 'Movies',
            },
            {
                'id': 6003397425735,
                'name': 'Tennis',
            },
            {
                'id': 6003659420716,
                'name': 'Cooking',
            },
        ],
    },
})
adset.remote_create(params={
    'status': AdSet.Status.active,
})
# _DOC close [ADSET_CREATE_INTERESTS_TARGETING]

adset.remote_delete()
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:ADSET_CREATE_INTERESTS_TARGETING.py

示例8: int

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
        AdSet.Field.bid_type: AdSet.BidType.cpm,  # Bidding for impressions
        AdSet.Field.bid_info: {
            AdSet.Field.BidInfo.impressions: 500,   # $5 per 1000 impression
        },
        AdSet.Field.daily_budget: 3600,  # $36.00
        AdSet.Field.start_time: int(time.time()) + 15,  # 15 seconds from now
        AdSet.Field.campaign_group_id: campaign.get_id_assured(),
        AdSet.Field.targeting: {
            TargetingSpecsField.geo_locations: {
                'countries': [
                    'US',
                ],
            },
        },
    })
    ad_set.remote_create()
    print("**** DONE: Ad Set created:")
    pp.pprint(ad_set)

    ### Upload an image to an account.
    img = AdImage(parent_id=my_account.get_id_assured())
    img[AdImage.Field.filename] = os.path.join(
        os.path.dirname(__file__),
        os.pardir,
        'facebookads/test/misc/image.png'
    )
    img.remote_create()
    print("**** DONE: Image uploaded:")
    pp.pprint(img)  # The image hash can be found using img[AdImage.Field.hash]

    ### Create a creative.
开发者ID:Evzdrop,项目名称:facebook-python-ads-sdk,代码行数:33,代码来源:create_ad.py

示例9: same_os_copy

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
    def same_os_copy(self, campaign, adset, adgroups):
        parent_id = config['act_id'][self.param['account']]
        account = AdAccount(parent_id)
        custom_audiences = account.get_custom_audiences(
            fields=[
                CustomAudience.Field.name,
            ],
            params={'limit': 100}
        )

        copy_custom_audience = []
        copy_excluded_custom_audience = []
        excluded_ids = self.param.getlist('excluded_custom_audiences')
        for i in range(0, len(custom_audiences)):
            custom_audience = custom_audiences[i]
            if custom_audience['id'] in self.param.getlist('custom_audiences'):
                audience = {
                    'id': custom_audience['id'],
                    'name': custom_audience['name']
                }
                copy_custom_audience.append(audience)
            if custom_audience['id'] in excluded_ids:
                excluded_audience = {
                    'id': custom_audience['id'],
                    'name': custom_audience['name']
                }
                copy_excluded_custom_audience.append(excluded_audience)

        copy_targeting = copy.deepcopy(adset['targeting'])
        copy_targeting['age_max'] = self.param['age_max']
        copy_targeting['age_min'] = self.param['age_min']
        copy_targeting['geo_locations']['countries'] = self.param.getlist('countries')
        copy_targeting['custom_audiences'] = copy_custom_audience
        copy_targeting['excluded_custom_audiences'] = copy_excluded_custom_audience

        # Defaults to all. Do not specify 0.
        if(self.param['gender']):
            copy_targeting['genders'] = [self.param['gender']]
        else:
            copy_targeting['genders'] = [1, 2]

        copy_adset = AdSet(parent_id=parent_id)
        copy_adset.update({
            AdSet.Field.name: self.param['adset_name'],
            AdSet.Field.daily_budget: adset['daily_budget'],
            AdSet.Field.promoted_object: adset['promoted_object'],
            AdSet.Field.is_autobid: adset['is_autobid'],
            AdSet.Field.targeting: copy_targeting,
            AdSet.Field.status: self.param['status'],
            AdSet.Field.campaign_group_id: self.param['campaign_id'],
            AdSet.Field.billing_event: adset['billing_event'],
            AdSet.Field.optimization_goal: adset['optimization_goal'],
            AdSet.Field.rtb_flag: adset['rtb_flag']
        })

        if 'bid_amount' in adset:
            copy_adset.update({
                AdSet.Field.bid_amount: adset['bid_amount']
            })

        copy_adset.remote_create()
        print("*** DONE: Copy AdSet ***")
        pp.pprint(copy_adset)

        adgroups = adset.get_ad_groups(
            fields=[
                AdGroup.Field.name,
                AdGroup.Field.creative,
                AdGroup.Field.tracking_specs,
                AdGroup.Field.status
            ],
            params={
                AdGroup.Field.status: ['ACTIVE']
            }
        )

        for i in range(0, len(adgroups)):
            adgroup = adgroups[i]
            copy_adgroup = AdGroup(parent_id=parent_id)
            copy_adgroup.update({
                AdGroup.Field.name: adgroup['name'],
                AdGroup.Field.campaign_id: copy_adset['id'],
                AdGroup.Field.status: adgroup['adgroup_status'],
                AdGroup.Field.creative: {
                    AdGroup.Field.Creative.creative_id: adgroup['creative']['id']
                },
                AdGroup.Field.tracking_specs: adgroup['tracking_specs']
            })
            copy_adgroup.remote_create()
            print("*** DONE: Copy AdGroup ***")
            pp.pprint(copy_adgroup)

        result = {
            'adset': copy_adset,
            'campaign': campaign,
            'adgroups': adgroups
        }

        return result
开发者ID:mixi-adtech,项目名称:facebook-tool,代码行数:101,代码来源:copy_ad_set_below.py

示例10: different_os_copy

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
    def different_os_copy(self, campaign, adset, adgroups):
        parent_id = config['act_id'][self.param['account']]
        link_url = config['link_url'][self.param['account']][self.param['os']]

        account = AdAccount(parent_id)
        custom_audiences = account.get_custom_audiences(
            fields=[
                CustomAudience.Field.name,
            ],
            params={'limit': 100}
        )

        copy_custom_audience = []
        copy_excluded_audience = []
        for i in range(0, len(custom_audiences)):
            custom_audience = custom_audiences[i]
            if custom_audience['id'] in self.param.getlist('custom_audiences'):
                audience = {
                    'id': custom_audience['id'],
                    'name': custom_audience['name']
                }
                copy_custom_audience.append(audience)
            if custom_audience['id'] in self.param.getlist('excluded_custom_audiences'):
                excluded_audience = {
                    'id': custom_audience['id'],
                    'name': custom_audience['name']
                }
                copy_excluded_audience.append(excluded_audience)

        copy_promoted_object = copy.deepcopy(adset['promoted_object'])
        copy_promoted_object['object_store_url'] = link_url

        copy_targeting = copy.deepcopy(adset['targeting'])
        copy_targeting['user_os'] = [config['user_os'][self.param['os']]]
        copy_targeting['age_max'] = self.param['age_max']
        copy_targeting['age_min'] = self.param['age_min']
        copy_targeting['geo_locations']['countries'] = self.param.getlist('countries')
        copy_targeting['custom_audiences'] = copy_custom_audience
        copy_targeting['excluded_custom_audiences'] = copy_excluded_audience

        # Default to all.
        if 'user_device' in copy_targeting:
            del copy_targeting['user_device']

        # Defaults to all. Do not specify 0.
        if(self.param['gender']):
            copy_targeting['genders'] = [self.param['gender']]
        else:
            copy_targeting['genders'] = [1, 2]

        copy_adset = AdSet(parent_id=parent_id)
        copy_adset.update({
            AdSet.Field.name: self.param['adset_name'],
            AdSet.Field.daily_budget: adset['daily_budget'],
            AdSet.Field.promoted_object: copy_promoted_object,
            AdSet.Field.is_autobid: adset['is_autobid'],
            AdSet.Field.targeting: copy_targeting,
            AdSet.Field.status: self.param['status'],
            AdSet.Field.campaign_group_id: self.param['campaign_id'],
            AdSet.Field.billing_event: adset['billing_event'],
            AdSet.Field.optimization_goal: adset['optimization_goal'],
            AdSet.Field.rtb_flag: adset['rtb_flag']
        })

        if 'bid_amount' in adset:
            copy_adset.update({
                AdSet.Field.bid_amount: adset['bid_amount']
            })
        copy_adset.remote_create()
        print("*** DONE: Copy AdSet ***")
        pp.pprint(copy_adset)

        creatives = adset.get_ad_creatives(
            fields=[
                AdCreative.Field.name,
                AdCreative.Field.object_story_spec
            ],
            params={
                'limit': 50
            }
        )

        for i in range(0, len(adgroups)):
            adgroup = adgroups[i]

            creative = {}
            for j in range(0, len(creatives)):
                if (adgroup['creative']['id'] == creatives[j]['id']):
                    creative = creatives[j]
                    break

            object_story_spec = creative['object_story_spec']
            if 'link_data' in object_story_spec:
                copy_object_story_spec = self.get_object_story_spec_for_image(
                    object_story_spec,
                    link_url
                )
            elif 'video_data' in object_story_spec:
                copy_object_story_spec = self.get_object_story_spec_for_video(
                    object_story_spec,
#.........这里部分代码省略.........
开发者ID:mixi-adtech,项目名称:facebook-tool,代码行数:103,代码来源:copy_ad_set_below.py

示例11: create_multiple_website_clicks_ads

# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import remote_create [as 别名]
def create_multiple_website_clicks_ads(
    account,

    name,
    country,

    titles,
    bodies,
    urls,
    image_paths,

    bid_type,
    bid_info,
    daily_budget=None,
    lifetime_budget=None,
    start_time=None,
    end_time=None,

    age_min=None,
    age_max=None,
    genders=None,

    campaign=None,
    paused=False,
):
    # Check for bad specs
    if daily_budget is None:
        if lifetime_budget is None:
            raise TypeError(
                'One of daily_budget or lifetime_budget must be defined.'
            )
        elif end_time is None:
            raise TypeError(
                'If lifetime_budget is defined, end_time must be defined.'
            )

    # Create campaign
    if not campaign:
        campaign = AdCampaign(parent_id=account.get_id_assured())
        campaign[AdCampaign.Field.name] = name + ' Campaign'
        campaign[AdCampaign.Field.objective] = \
            AdCampaign.Objective.website_clicks
        campaign[AdCampaign.Field.status] = \
            AdCampaign.Status.active if not paused \
            else AdCampaign.Status.paused
        campaign.remote_create()

    # Create ad set
    ad_set = AdSet(parent_id=account.get_id_assured())
    ad_set[AdSet.Field.campaign_group_id] = campaign.get_id_assured()
    ad_set[AdSet.Field.name] = name + ' AdSet'
    ad_set[AdSet.Field.bid_type] = bid_type
    ad_set[AdSet.Field.bid_info] = bid_info
    if daily_budget:
        ad_set[AdSet.Field.daily_budget] = daily_budget
    else:
        ad_set[AdSet.Field.lifetime_budget] = lifetime_budget
    if end_time:
        ad_set[AdSet.Field.end_time] = end_time
    if start_time:
        ad_set[AdSet.Field.start_time] = start_time
    targeting = {}
    targeting[TargetingSpecsField.geo_locations] = {
        'countries': [country]
    }
    if age_max:
        targeting[TargetingSpecsField.age_max] = age_max
    if age_min:
        targeting[TargetingSpecsField.age_min] = age_min
    if genders:
        targeting[TargetingSpecsField.genders] = genders
    ad_set[AdSet.Field.targeting] = targeting
    ad_set.remote_create()

    # Upload the images first one by one
    image_hashes = []
    for image_path in image_paths:
        img = AdImage(parent_id=account.get_id_assured())
        img[AdImage.Field.filename] = image_path
        img.remote_create()
        image_hashes.append(img.get_hash())

    ADGROUP_BATCH_CREATE_LIMIT = 10
    ad_groups_created = []

    def callback_failure(response):
        raise response.error()

    # For each creative permutation
    for creative_info_batch in generate_batches(
        itertools.product(titles, bodies, urls, image_hashes),
        ADGROUP_BATCH_CREATE_LIMIT
    ):
        api_batch = account.get_api_assured().new_batch()

        for title, body, url, image_hash in creative_info_batch:
            # Create the ad
            ad = AdGroup(parent_id=account.get_id_assured())
            ad[AdGroup.Field.name] = name + ' Ad'
            ad[AdGroup.Field.campaign_id] = ad_set.get_id_assured()
#.........这里部分代码省略.........
开发者ID:Evzdrop,项目名称:facebook-python-ads-sdk,代码行数:103,代码来源:ad_creation_utils.py


注:本文中的facebookads.objects.AdSet.remote_create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。