Python Facebook API v3.1

时间:2018-09-26 15:49:38

标签: python facebook facebook-graph-api facebook-marketing-api facebook-python-business-sdk

我是facebook API的新手,我一直在浏览示例给定的here代码,因此我一直在通过替换与凭证相关的变量来调用AdsInsightsEdgeAdCampaignInsights.py的脚本。但是我收到如下错误:

  Message: Call was not successful
  Method:  GET
  Path:    https://graph.facebook.com/v2.11/10153882624547484/insights
  Params:  {'breakdown': 'publisher_platform', 'fields': 'impressions'}

  Status:  400
  Response:
    {
      "error": {
        "message": "Unsupported operation", 
        "code": 100, 
        "type": "OAuthException", 
        "fbtrace_id": "A/HinNJOAqs"
      }
    } 

我有以下查询:

  1. 为什么要调用https://graph.facebook.com/v2.11/10153882624547484/insights,为什么要使用版本v2.11

  2. 如何使用API​​版本v3.1进行调用?

  3. 任何适用于v3.1的Python Facebook API文档

1 个答案:

答案 0 :(得分:0)

Hej Piyush,

我认为它正在调用v2.11而不是v3.1,因为在AdsInsightsEdgeAdCampaignInsights.py的import语句中,它调用from facebookads,其中从v3.0开始,Facebook合并了所有Advertiser&Business API,并称为模块facebook_business

我自己进行了测试,并将其更改为

from facebook_business.adobjects.adsetimport AdSet
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.api import FacebookAdsApi

对我有用。

在谈到自己的API文档并进行适当更新时,我认为Facebook相当草率。