我正在尝试使用Python和请求库访问其中一位客户的广告数据。我有访问令牌和AdAccountId。
我能够获得见解,但找不到获取广告集或广告的开始日期和结束日期的方法。
有名为date_start和date_stop的列,它们显然是报告的开始和结束日期。
我一直在使用的代码是:
import request
url = "https://graph.facebook.com/v4.0/act_{00000000000}/ads/"
querystring = {'time_range':'{"since":"2019-01-01", "until":"2019-11-20"}','limit':'1000','date_preset':"lifetime","fields":"campaign_id,configured_status,created_time,effective_status,start_time,end_time,insights{campaign_name,adset_id,adset_name,ad_id,ad_name,clicks,reach,spend,social_spend,impressions,unique_clicks,cost_per_unique_click,cost_per_ad_click,website_ctr,purchase_roas,website_purchase_roas,objective}"}
headers = {
'Authorization': "Token",
'Postman-Token': "Postman-Token",
'Host': "graph.facebook.com",
'Accept-Encoding': "gzip, deflate",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring)
res1 = response.json()
print(res1)
我的输出是
{'数据':[{'campaign_id':'24585475576855458','configured_status':'ACTIVE','created_time':'2019-07-17T12:43:35 + 0530','effective_status':'ACTIVE ','insights':{'data':[{'campaign_name':'Campaign_name','adset_id':'24854165715688142','adset_name':'adset_name','ad_id':'2558858658585865','ad_name':' ad_name”,“ clicks”:“ 0”,“ reach”:“ 115”,“ spend”:“ 20.07”,“ social_spend”:“ 0.14”,“ impressions”:“ 120”,“ unique_clicks”:“ 0” ,'objective':'CONVERSIONS','date_start':'2019-10-29','date_stop':'2019-11-27'}],'paging':{'cursors':{'before':' MAZDZD”,“之后”:“ MAZDZD”}}}
顺便说一句,我只能访问帐户ID和访问令牌。
使用上述方法或实现此目的的更好方法,对如何获得广告或广告集的开始和结束日期有帮助吗?