本文整理汇总了Python中facebookads.objects.AdSet类的典型用法代码示例。如果您正苦于以下问题:Python AdSet类的具体用法?Python AdSet怎么用?Python AdSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AdSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_adsets
def get_adsets(adset_id):
adset = AdSet(adset_id)
fields = [
AdSet.Field.name,
]
adset.remote_read(fields=fields)
return adset
示例2: copy
def copy(self):
store_url = config['link_url'][self.param['account']][self.param['os']]
link_url = store_url.replace('https://', 'http://')
campaign = AdCampaign(self.param['campaign_id'])
campaign.remote_read(
fields=[
AdCampaign.Field.name
]
)
adset = AdSet(self.param['adset_id'])
adset.remote_read(
fields=[
AdSet.Field.name,
AdSet.Field.daily_budget,
AdSet.Field.pacing_type,
AdSet.Field.promoted_object,
AdSet.Field.targeting,
AdSet.Field.is_autobid,
AdSet.Field.billing_event,
AdSet.Field.optimization_goal,
AdSet.Field.bid_amount,
AdSet.Field.rtb_flag
]
)
# pp.pprint(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']
}
)
# pp.pprint(adgroups)
object_store_url = adset['promoted_object']['object_store_url']
replace_url = object_store_url.replace('https://', 'http://')
if link_url != replace_url:
return self.different_os_copy(campaign, adset, adgroups)
else:
return self.same_os_copy(campaign, adset, adgroups)
示例3: create_adset
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
示例4: create_adset
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
示例5: create_ad_set
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]
示例6: AdSet
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
from facebookads import test_config
ad_account_id = test_config.account_id
campaign_id = fixtures.create_campaign().get_id_assured()
page_id = test_config.page_id
# _DOC oncall [paulbain]
# _DOC open [ADSET_CREATE_BEHAVIORAL_TARGETING]
# _DOC vars [ad_account_id:s, campaign_id, page_id]
from facebookads.objects import AdSet, TargetingSpecsField
adset = AdSet(parent_id=ad_account_id)
adset.update({
AdSet.Field.name: 'My AdSet',
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
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.promoted_object: {'page_id': page_id},
AdSet.Field.targeting: {
TargetingSpecsField.geo_locations: {
'countries': ['JP'],
'regions': [
{'key': '3886'},
],
'cities': [
示例7: AdSet
from facebookads import test_config
from facebookads.objects import Campaign
ad_account_id = test_config.account_id
app_id, app_store_url = fixtures.get_promotable_ios_app()
params = {
Campaign.Field.objective: Campaign.Objective.conversions,
}
campaign_id = fixtures.create_campaign(params).get_id_assured()
# _DOC open [ADSET_CREATE_CPA_APP_EVENTS]
# _DOC vars [ad_account_id:s, app_id, campaign_id, app_store_url:s]
import time
from facebookads.objects import AdSet
adset = AdSet(parent_id=ad_account_id)
adset.update({
AdSet.Field.name: 'LifetimeBudgetSet',
AdSet.Field.campaign_id: campaign_id,
AdSet.Field.lifetime_budget: 10000,
AdSet.Field.start_time: int(time.time()),
AdSet.Field.end_time: int(time.time() + 100000),
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.offsite_conversions,
AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
AdSet.Field.bid_amount: 500,
AdSet.Field.promoted_object: {
'application_id': app_id,
'object_store_url': app_store_url,
'custom_event_type': 'ADD_TO_CART',
},
AdSet.Field.targeting: {
示例8: Campaign
### Get first account connected to the user
my_account = me.get_ad_account()
### Create a Campaign
campaign = Campaign(parent_id=my_account.get_id_assured())
campaign.update({
Campaign.Field.name: 'Seattle Ad Campaign',
Campaign.Field.objective: 'LINK_CLICKS',
Campaign.Field.effective_status: Campaign.Status.paused,
})
campaign.remote_create()
print("**** DONE: Campaign created:")
pp.pprint(campaign)
### Create an Ad Set
ad_set = AdSet(parent_id=my_account.get_id_assured())
ad_set.update({
AdSet.Field.name: 'Puget Sound AdSet',
AdSet.Field.effective_status: AdSet.Status.paused,
AdSet.Field.daily_budget: 3600, # $36.00
AdSet.Field.billing_event: 'IMPRESSIONS', # $36.00
AdSet.Field.is_autobid: 'true', # $36.00
AdSet.Field.start_time: int(time.time()) + 15, # 15 seconds from now
AdSet.Field.campaign_id: campaign.get_id_assured(),
AdSet.Field.targeting: {
TargetingSpecsField.geo_locations: {
'countries': [
'US',
],
},
},
示例9: AdSet
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
from facebookads import test_config
ad_account_id = test_config.account_id
campaign_id = fixtures.create_campaign().get_id()
product_set_id = fixtures.create_product_set().get_id()
dynamic_audience_id = fixtures.create_product_audience(product_set_id).get_id()
# _DOC open [ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION]
# _DOC vars [ad_account_id:s, dynamic_audience_id, campaign_id, product_set_id]
from facebookads.objects import AdSet, TargetingSpecsField
adset = AdSet(parent_id=ad_account_id)
adset[AdSet.Field.name] = 'Product Catalog Sales 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.product_audience_specs: [
{
'product_set_id': product_set_id,
'inclusions': [
{
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:31,代码来源:ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION.py
示例10: AdSet
ad_account_id = test_config.account_id
product_catalog_id = fixtures.create_product_catalog().get_id()
product_set_id = fixtures.create_product_set(product_catalog_id).get_id()
params = {
Campaign.Field.objective: Campaign.Objective.product_catalog_sales,
Campaign.Field.promoted_object: {'product_catalog_id': product_catalog_id},
}
campaign_id = fixtures.create_campaign(params).get_id_assured()
# _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',
}],
}
示例11: AdSet
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
from facebookads import test_config
ad_account_id = test_config.account_id
connections_id = test_config.page_id
campaign_id = fixtures.create_campaign().get_id_assured()
# _DOC open [ADSET_CREATE_APP_CONNECTIONS_TARGETING]
# _DOC vars [ad_account_id:s, campaign_id, connections_id]
from facebookads.objects import AdSet, TargetingSpecsField
ad_set = AdSet(parent_id=ad_account_id)
ad_set.update({
AdSet.Field.name: 'Android Connections Targeting - Ad Set',
AdSet.Field.campaign_id: campaign_id,
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.post_engagement,
AdSet.Field.billing_event: AdSet.BillingEvent.post_engagement,
AdSet.Field.bid_amount: 1500,
AdSet.Field.daily_budget: 10000,
AdSet.Field.targeting: {
TargetingSpecsField.geo_locations: {
'countries': ['US'],
},
TargetingSpecsField.connections: [connections_id],
TargetingSpecsField.user_os: ['Android'],
},
})
示例12: AdSet
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
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)
示例13: AdSet
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
from facebookads import test_config
ad_account_id = test_config.account_id
campaign_id = fixtures.create_campaign().get_id_assured()
# _DOC open [ADSET_CREATE_FLEXIBLE_TARGETING]
# _DOC vars [ad_account_id:s, campaign_id]
from facebookads.objects import AdSet
adset = AdSet(parent_id=ad_account_id)
adset.update({
AdSet.Field.name: 'My AdSet',
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
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'],
},
'age_min': 18,
'age_max': 43,
'flexible_spec': [
{
示例14: AdSet
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
from facebookads import test_config
ad_account_id = test_config.account_id
campaign_id = fixtures.create_campaign().get_id_assured()
# _DOC open [ADSET_CREATE_LOCATION_DEMOGRAPHIC_INTERESTS_TARGETING]
# _DOC vars [ad_account_id:s, campaign_id]
from facebookads.objects import AdSet
adset = AdSet(parent_id=ad_account_id)
adset.update({
AdSet.Field.name: 'My AdSet',
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
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': {
'regions': [{
'key': '3847'
}],
'cities': [
{
'key': '2430536',
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:31,代码来源:ADSET_CREATE_LOCATION_DEMOGRAPHIC_INTERESTS_TARGETING.py
示例15: AdSet
# As with any software that integrates with the Facebook platform, your use
# of this software is subject to the Facebook Developer Principles and
# Policies [http://developers.facebook.com/policy/]. This copyright notice
# shall be included in all copies or substantial portions of the software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from examples.docs import fixtures
ad_set_id = fixtures.create_adset().get_id()
# _DOC open [ADSET_GET_INSIGHTS_LEVEL_ADGROUP]
# _DOC vars [ad_set_id]
from facebookads.objects import AdSet, Insights
adset = AdSet(fbid=ad_set_id)
params = {
'level': Insights.Level.ad
}
stats = adset.get_insights(params=params)
print(stats)
# _DOC close [ADSET_GET_INSIGHTS_LEVEL_ADGROUP]