为什么我无法使用api获取facebook ad-group stats?

时间:2015-01-04 15:14:24

标签: python facebook facebook-graph-api facebook-ads-api

我正在尝试使用facebook-ads python包从广告组中提取统计信息,方法是应用" get_conversion_stats" AdGroup对象的方法(类' facebookads.objects.AdGroup')。

accounts = me.get_ad_accounts(fields=['name', 'account_status'])
accounts_list = list(accounts)
for accounti in accounts_list:
campaign = accounti.get_ad_campaigns(fields=[facebookads.objects.AdCampaign.Field.name])
campaign_list = list(campaign)
for campaigni in campaign_list:
    adset = campaigni.get_ad_sets(fields=["name"])
    adset_list = list(adset)
    for adseti in adset_list:
        adgroups = adseti.get_ad_groups()
        adgroups_list = list(adgroups)
        for adgroupi in adgroups_list:
            adgroup = AdGroup(str(adgroupi["id"]))
            adgroup.remote_read(fields=[AdGroup.Field.name, AdGroup.Field.campaign_id])
            adgroup_conv = accounti.get_ad_group_conversion_stats()
            print accounti["name"]+", "+campaigni["name"]+", "+adseti["name"]+", "+str(adgroupi["id"])

我收到以下错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\facebookads\objects.py", line 1283, in get_conversion_stats
return self.edge_object(ConversionStats, fields, params)
  File "C:\Python27\lib\site-packages\facebookads\objects.py", line 708, in edge_object
    params=params
  File "C:\Python27\lib\site-packages\facebookads\objects.py", line 96, in __next__
if not self._queue and not self.load_next_page():
  File "C:\Python27\lib\site-packages\facebookads\objects.py", line 125, in load_next_page
for json_obj in response['data']:
KeyError: 'data'

此对象和方法的文档可在此处找到: https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/objects.py

我无法弄清楚哪些是错的,我很感激你能给我的任何帮助。

谢谢!

0 个答案:

没有答案