本文整理汇总了Python中facebookads.objects.AdAccount类的典型用法代码示例。如果您正苦于以下问题:Python AdAccount类的具体用法?Python AdAccount怎么用?Python AdAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AdAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_adsets_from_adaccount
def get_adsets_from_adaccount(account_id):
account = AdAccount(account_id)
fields = [
AdSet.Field.name,
]
adsets = account.get_ad_sets(fields=fields)
return adsets
示例2: getCustomAudiences
def getCustomAudiences(my_account):
ad_account = AdAccount("{AD_ACCOUNT_ID}".format(AD_ACCOUNT_ID = my_account['id']))
custom_audiences = ad_account.get_custom_audiences(fields=[CustomAudience.Field.name])
# audiences = my_account.get_custom_audiences(fields=[
# CustomAudience.Field.name,
# CustomAudience.Field.description])
return custom_audiences
示例3: create_ads_pixel
def create_ads_pixel():
account = AdAccount(test_config.account_id)
pixel = account.get_ads_pixels([AdsPixel.Field.code])
if pixel is None:
pixel = AdsPixel(parent_id=test_config.account_id)
pixel[AdsPixel.Field.name] = unique_name('Test Pixel')
pixel.remote_create()
return pixel
示例4: get_ads_insight
def get_ads_insight(
self,
account_id,
):
"""
Pull insights from the Insight edge and return an array of
insight report
Params:
* `account_id` is fb AdAccount id
"""
ad_account = AdAccount(fbid = account_id)
insights = ad_account.get_insights()
return insights
示例5: get_promotable_ios_app
def get_promotable_ios_app(app_id=None):
account = AdAccount(test_config.account_id)
for connection_object in account.get_connection_objects():
if connection_object[ConnectionObject.Field.type] == 2 \
and (
app_id is None
or int(
connection_object[ConnectionObject.Field.id],
) is int(app_id)
):
if 'object_store_urls' in connection_object \
and 'itunes' in connection_object['object_store_urls']:
return (
connection_object[ConnectionObject.Field.id],
connection_object['object_store_urls']['itunes']
)
raise Exception('No iOS promotable App available')
示例6: get_ad_set
def get_ad_set(self):
account = AdAccount(self.act_id)
adsets = account.get_ad_sets(
fields=[
AdSet.Field.name,
AdSet.Field.status,
AdSet.Field.campaign_group_id
],
params={
'campaign_status': ['ACTIVE'],
'limit': 100
}
)
campaigns = account.get_ad_campaigns(
fields=[
AdCampaign.Field.name,
AdCampaign.Field.status
],
params={
'campaign_group_status': ['ACTIVE']
}
)
ads = []
for adset in adsets:
for i in range(0, len(campaigns)):
campaign = campaigns[i]
if adset['campaign_group_id'] == campaign['id']:
ads.append({
'id': adset['id'],
'name': adset['name'],
'campaign_name': campaign['name']
})
break
return sorted(ads, key=lambda ad: ad['campaign_name'] + ad['name'])
示例7: AdAccount
# 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 facebookads import test_config
ad_account_id = test_config.account_id
# _DOC open [ADACCOUNT_GET_INSIGHTS_FILTERING_BREAKDOWN]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount, Insights
ad_account = AdAccount(ad_account_id)
params = {
'breakdowns': [
Insights.Breakdown.age,
Insights.Breakdown.gender
],
'filtering': [{
'field': 'campaign.name',
'operator': 'CONTAIN',
'value': '18-25'
}]
}
stats = ad_account.get_insights(params=params)
print(stats)
# _DOC close [ADACCOUNT_GET_INSIGHTS_FILTERING_BREAKDOWN]
示例8: AdAccount
# Facebook.
# 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 facebookads import test_config
from facebookads.objects import AdAccount
ad_account_id = test_config.account_id
account = AdAccount(ad_account_id)
# _DOC open [ADACCOUNT_GET_CONNECTIONOBJECTS_ID_NAME_TYPE]
from facebookads.objects import ConnectionObject
account.get_connection_objects([
ConnectionObject.Field.id,
ConnectionObject.Field.name,
ConnectionObject.Field.type,
])
# _DOC close [ADACCOUNT_GET_CONNECTIONOBJECTS_ID_NAME_TYPE]
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:30,代码来源:ADACCOUNT_GET_CONNECTIONOBJECTS_ID_NAME_TYPE.py
示例9: AdAccount
# 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
from facebookads import test_config
ad_account_id = test_config.account_id
ad_label_id = fixtures.create_adlabel().get_id()
# _DOC oncall [pruno]
# _DOC open [ADACCOUNT_GET_ADGROUPS_FILTERING_ADLABELS]
# _DOC vars [ad_account_id:s, ad_label_id]
from facebookads.objects import AdAccount, Ad
params = {
'filtering': [
{
'field': 'adlabels',
'operator': 'ANY',
'value': ['for testing'],
},
],
}
ad_account = AdAccount(ad_account_id)
ads = ad_account.get_ads(fields=[Ad.Field.name], params=params)
# _DOC close [ADACCOUNT_GET_ADGROUPS_FILTERING_ADLABELS]
示例10: AdAccount
# 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
from facebookads import test_config
from facebookads.objects import AdPreview
ad_account_id = test_config.account_id
post_id = fixtures.create_post()['id']
format = AdPreview.AdFormat.desktop_feed_standard
# _DOC open [ADACCOUNT_GET_PREVIEWS_WITH_OBJECT_STORY_ID]
# _DOC vars [ad_account_id:s, post_id:s, format:s]
from facebookads.objects import AdAccount, AdPreview, AdCreative
account = AdAccount(ad_account_id)
params = {
AdPreview.Field.creative: {
AdCreative.Field.object_story_id: post_id,
},
AdPreview.Field.ad_format: format,
}
account.get_ad_preview(params=params)
# _DOC close [ADACCOUNT_GET_PREVIEWS_WITH_OBJECT_STORY_ID]
示例11: AdAccount
# Facebook.
# 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 facebookads import test_config
ad_account_id = test_config.account_id
# _DOC oncall [pruno]
# _DOC open [ADACCOUNT_GET_CUSTOMAUDIENCES_DATA_SOURCE_SUBTYPE]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount, CustomAudience
ad_account = AdAccount(ad_account_id)
custom_audiences = ad_account.get_custom_audiences(fields=[
CustomAudience.Field.data_source,
CustomAudience.Field.subtype,
])
# _DOC close [ADACCOUNT_GET_CUSTOMAUDIENCES_DATA_SOURCE_SUBTYPE]
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:30,代码来源:ADACCOUNT_GET_CUSTOMAUDIENCES_DATA_SOURCE_SUBTYPE.py
示例12: open
from facebookads.objects import AdAccount, AsyncJob
from facebookads.api import FacebookAdsApi
import time
import os
import json
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')
config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
api = FacebookAdsApi.init(access_token=config['access_token'])
account_id = config['act_id']
account = AdAccount(account_id)
# Both Insights and Reportstats
i_async_job = account.get_insights(params={'level': 'ad'}, async=True)
# Insights
while True:
job = i_async_job.remote_read()
print("Percent done: " + str(job[AsyncJob.Field.async_percent_completion]))
time.sleep(1)
if job:
# print "Done!"
break
print(i_async_job.get_result())
示例13: AdAccount
# use, copy, modify, and distribute this software in source code or binary
# form for use in connection with the web services and APIs provided by
# Facebook.
# 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 facebookads import test_config
ad_account_id = test_config.account_id
# _DOC open [ADACCOUNT_GET_ADCAMPAIGNS]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount, Campaign
account = AdAccount(ad_account_id)
campaigns = account.get_campaigns(fields=[Campaign.Field.name])
for campaign in campaigns:
print(campaign[Campaign.Field.name])
# _DOC close [ADACCOUNT_GET_ADCAMPAIGNS]
示例14: AdAccount
# 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 facebookads import test_config
ad_account_id = test_config.account_id
# _DOC open [ADACCOUNT_GET_INSIGHTS_DYNAMIC_PRODUCT_ADS]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount, Insights
account = AdAccount(ad_account_id)
fields = [
Insights.Field.account_name,
Insights.Field.impressions,
Insights.Field.actions,
Insights.Field.product_id,
]
params = {
'date_preset': 'last_week',
'actions_group_by': ['action_type'],
}
stats = account.get_insights(fields=fields, params=params)
# _DOC close [ADACCOUNT_GET_INSIGHTS_DYNAMIC_PRODUCT_ADS]
示例15: AdAccount
# 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 facebookads import test_config
ad_account_id = test_config.account_id
# _DOC open [ADACCOUNT_GET_ADGROUPS_WITH_STATUS]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount
account = AdAccount(ad_account_id)
params = {
'effective_status': ['ACTIVE',
'ADSET_PAUSED',
'CAMPAIGN_PAUSED',
'PENDING_REVIEW',
'DISAPPROVED',
'PREAPPROVED',
'PENDING_BILLING_INFO',
'ARCHIVED',
]
}
ads = account.get_ads(params=params)
for ad in ads:
print(ad)
# _DOC close [ADACCOUNT_GET_ADGROUPS_WITH_STATUS]