Created
May 5, 2019 17:00
-
-
Save olitomas/447e48cca1d5e85e3aaac9fad33efa84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from facebook_business.adobjects.adaccount import AdAccount | |
from facebook_business.api import FacebookAdsApi | |
from facebook_business.adobjects.adset import AdSet | |
from facebook_business.adobjects.adsinsights import AdsInsights | |
import arrow | |
my_access_token = 'xxx' | |
my_app_id = 'xxx' | |
my_app_secret = 'xxx' | |
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token) | |
my_account = AdAccount('xxx') | |
fields = [ | |
'impressions', | |
'spend', | |
'conversions' | |
] | |
params = { | |
'time_ranges': [ | |
{'since': '2019-05-05', 'until': '2019-06-06'} | |
] | |
} | |
def get_insights(): | |
return insights = my_account.get_insights(fields=fields, params=params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment