i'have an issue to write my api call into one csv file . I'm new on Python, looked arround stackoverflow but can't figure it out . Anyone has an idea how to do it exactly ?
here is the answer ot the call https://i.stack.imgur.com/HqBm1.jpg
here is how i would like to get the https://i.stack.imgur.com/eKpeu.jpg
Many thanks,
and here is the code
import datetime
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adsinsights import AdsInsights
from facebookads.api import FacebookAdsApi
start_date = datetime.date.fromordinal(datetime.date.today().toordinal()-1).strftime("%F")
end_date = datetime.date.fromordinal(datetime.date.today().toordinal()-1).strftime("%F")
access_token = 'xxx'
ad_account_id = 'act_xx'
##app_secret = 'xxx'
FacebookAdsApi.init(access_token=access_token)
fields = [
'campaign_name',
'impressions',
'clicks',
'social_impressions',
'total_actions',
]
params = {
'time_range': {'since':start_date,'until':end_date},
## 'filtering': [],
'level': 'campaign',
##'breakdowns': ['days_1'],
}
print (AdAccount(ad_account_id).get_insights(
fields=fields,
params=params,
))
when trying the solution of N. Ivanov , i still get an error regarding :
f = csv.writer(open'testfbhh.csv', 'wb+'