本文整理汇总了Python中facebookads.objects.AdAccount.get_report_stats方法的典型用法代码示例。如果您正苦于以下问题:Python AdAccount.get_report_stats方法的具体用法?Python AdAccount.get_report_stats怎么用?Python AdAccount.get_report_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类facebookads.objects.AdAccount
的用法示例。
在下文中一共展示了AdAccount.get_report_stats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AdAccount
# 需要导入模块: from facebookads.objects import AdAccount [as 别名]
# 或者: from facebookads.objects.AdAccount import get_report_stats [as 别名]
# _DOC open [ADACCOUNT_GET_REPORTSTATS_DYNAMIC_PRODUCT_ADS]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount
account = AdAccount(ad_account_id)
params = {
'data_columns': [
'account_name', 'impressions', 'clicks', 'actions', 'product_id'
],
'date_preset': 'last_week',
'actions_group_by': ['action_type'],
}
stats = account.get_report_stats(params=params)
# _DOC close [ADACCOUNT_GET_REPORTSTATS_DYNAMIC_PRODUCT_ADS]
ad_label_id = fixtures.create_adlabel().get_id()
# _DOC open [ADACCOUNT_GET_ADLABELS]
# _DOC vars [ad_account_id:s]
from facebookads.objects import AdAccount
from facebookads.objects import AdLabel
account = AdAccount(ad_account_id)
adlabels = account.get_ad_labels()
for adlabel in adlabels:
print(adlabel[AdLabel.Field.name])
示例2: open
# 需要导入模块: from facebookads.objects import AdAccount [as 别名]
# 或者: from facebookads.objects.AdAccount import get_report_stats [as 别名]
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': 'adgroup'}, async=True)
r_async_job = account.get_report_stats(
params={
'data_columns': ['adgroup_id'],
'date_preset': 'last_30_days'
},
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())