本文整理汇总了Python中facebookads.objects.AdSet.get_id_assured方法的典型用法代码示例。如果您正苦于以下问题:Python AdSet.get_id_assured方法的具体用法?Python AdSet.get_id_assured怎么用?Python AdSet.get_id_assured使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类facebookads.objects.AdSet
的用法示例。
在下文中一共展示了AdSet.get_id_assured方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import get_id_assured [as 别名]
print("**** DONE: Image uploaded:")
pp.pprint(img) # The image hash can be found using img[AdImage.Field.hash]
### Create a creative.
creative = AdCreative(parent_id=my_account.get_id_assured())
creative.update({
AdCreative.Field.title: 'Visit Seattle',
AdCreative.Field.body: 'Beautiful Puget Sound!',
AdCreative.Field.object_url: 'http://www.seattle.gov/visiting/',
AdCreative.Field.image_hash: img.get_hash(),
})
creative.remote_create()
print("**** DONE: Creative created:")
pp.pprint(creative)
### Get excited, we are finally creating an ad!!!
ad = Ad(parent_id=my_account.get_id_assured())
ad.update({
Ad.Field.name: 'Puget Sound impression ad',
Ad.Field.adset_id: ad_set.get_id_assured(),
Ad.Field.creative: {
Ad.Field.Creative.creative_id: creative.get_id_assured(),
},
})
ad.remote_create(params={
'status': AdSet.Status.paused,
})
print("**** DONE: Ad created:")
pp.pprint(ad)
示例2: print
# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import get_id_assured [as 别名]
'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.
creative = AdCreative(parent_id=my_account.get_id_assured())
creative.update({
AdCreative.Field.title: 'Visit Seattle',
AdCreative.Field.body: 'Beautiful Puget Sound!',
AdCreative.Field.object_url: 'http://www.seattle.gov/visiting/',
AdCreative.Field.image_hash: img.get_hash(),
})
creative.remote_create()
print("**** DONE: Creative created:")
pp.pprint(creative)
### Get excited, we are finally creating an ad!!!
ad = AdGroup(parent_id=my_account.get_id_assured())
ad.update({
AdGroup.Field.name: 'Puget Sound impression ad',
AdGroup.Field.campaign_id: ad_set.get_id_assured(),
AdGroup.Field.creative: {
AdGroup.Field.Creative.creative_id: creative.get_id_assured(),
},
})
ad.remote_create()
print("**** DONE: Ad created:")
pp.pprint(ad)
示例3: create_multiple_website_clicks_ads
# 需要导入模块: from facebookads.objects import AdSet [as 别名]
# 或者: from facebookads.objects.AdSet import get_id_assured [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()
#.........这里部分代码省略.........