Python facebookads sdk - 找不到publisher_platform故障

标签 python facebook python-2.7 facebook-ads-api facebook-marketing-api

我正在尝试使用 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))}
})

关于Python facebookads sdk - 找不到publisher_platform故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41729593/

相关文章:

facebook - 有人可以结束 "LEAVE APP"的痛苦吗!

针对 SQLite 数据库的 C# 与 Python 查询

facebook - 用于关联目的的共享网址中的哈希(字符)在 Wall 中被删除

c# - 无法为 Facebook 创建 SSL/TLS 安全通道

python - 打开 putty 窗口并运行 ssh 命令 - Python

html - 我在静态文件夹中的图像没有显示

Python 2.7 将于 2020 年 1 月 1 日结束其生命周期

python - 对永远重复的循环的第一个实例执行操作

python - Django 序列化器将模型字段显示为字典

python - pytorch 在张量的某个维度上调用 unique_consecutive() 的最佳方法?