Python Facebook API v3.1

303 Views Asked by At

I am new to facebook API, I was looking through the code given here with example so I have been calling script for AdsInsightsEdgeAdCampaignInsights.py by replacing the credential related variables . But I am getting an error as follows :

  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"
      }
    } 

I have following queries:

  1. why it is calling https://graph.facebook.com/v2.11/10153882624547484/insights , why version v2.11?

  2. How should I call using API version v3.1?

  3. Any Python Facebook API documentation for v3.1

1

There are 1 best solutions below

0
On

Hej Piyush,

I think it is calling v2.11 instead of v3.1 because in the import statement for AdsInsightsEdgeAdCampaignInsights.py, it calls from facebookads where as from v3.0 onwards, Facebook merged all the Advertiser & Business APIs and called the module facebook_business.

I tested it for myself and after changing it to

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

it worked for me.

When it comes to the documentation of their own API and updating it properly, Facebook is pretty sloppy in my opinion.