我正在尝试使用facebookads Python SDK来获取“平台”(有时甚至是“ publisher_platform”)细分,因为我们在Facebook和Instagram上投放广告。这是我的代码:

insights = account.get_insights(fields=[
    AdsInsights.Field.ad_id,
    AdsInsights.Field.impressions,
    AdsInsights.Field.reach,
    AdsInsights.Field.spend,
], params={
    'level': AdsInsights.Level.ad,
    'breakdowns': AdsInsights.Breakdowns.publisher_platform,
    'time_range': {'since': str(datetime.date(2016,12,1)), 'until': str(datetime.date(2016,12,31))}
})


该代码引发以下错误消息:

Traceback (most recent call last):
  File "<stdin>", line 8, in <module>
AttributeError: class Breakdowns has no attribute 'publisher_platform'


除8号线外,其他所有东西都在工作。如何解决此问题?

最佳答案

看来它实际上是SDK中所缺少的。看到这种问题时,您只需签入文件即可查看该文件是否存在。

在SDK中可用之前,您只能使用字符串:

insights = account.get_insights(fields=[
    AdsInsights.Field.ad_id,
    AdsInsights.Field.impressions,
    AdsInsights.Field.reach,
    AdsInsights.Field.spend,
], params={
    'level': AdsInsights.Level.ad,
    'breakdowns': 'publisher_platform',
    'time_range': {'since': str(datetime.date(2016,12,1)), 'until': str(datetime.date(2016,12,31))}
})

10-06 09:31