本文整理匯總了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())