Facebook Reporting API -- Facebook 数据导出API

时间:2024-01-21 08:18:15

  1、获取token

  浏览器打开 "访问口令工具" (FB链接请FQ)  https://developers.facebook.com/tools/accesstoken/

    

    App Token  "|"  号前的为 Appid,整个字符串为 access_token.

 

  2、访问接口,获取广告数据  

post请求   https://graph.facebook.com/<API_VERSION>/<APP_ID|BUSINESS_ID|PROPERTY_ID>/adnetworkanalytics/?
  metrics=['fb_ad_network_imp']&
  access_token=<ACCESS_TOKEN> 

例如:https://graph.facebook.com/v2.12/Appid/adnetworkanalytics/?metrics=['fb_ad_network_request','fb_ad_network_imp']&since=2018-08-10&until=2018-08-11&access_token=access_token

返回数据
{

  "query_id": "1761********",

    "async_result_link": "https://graph.facebook.com/v2.12/192314334639400/adnetworkanalytics_results?******************"
 }

  3、获取数据。用第二步得到的返回数据 async_result_link 再次访问。

 

 get 请求   https://graph.facebook.com/v2.12/192314334639400/adnetworkanalytics_results?******************

 

  返回值,得到相应日期广告的请求和展示

    "data": [
        {
            "query_id": "1761********",
            "status": "complete",
            "results": [
                {
                    "time": "2018-08-11T07:00:00+0000",
                    "metric": "fb_ad_network_request",
                    "value": "121212"
                },
                {
                    "time": "2018-08-10T07:00:00+0000",
                    "metric": "fb_ad_network_request",
                    "value": "121212"
                },
                {
                    "time": "2018-08-11T07:00:00+0000",
                    "metric": "fb_ad_network_imp",
                    "value": "111111"
                },
                {
                    "time": "2018-08-10T07:00:00+0000",
                    "metric": "fb_ad_network_imp",
                    "value": "111111"
                }
            ]
} ] }

  4、分类查询,按国家、按广告位等  参数  breakdowns

  访问链接添加  breakdowns=["placement","country"]

例如: 
https://graph.facebook.com/v2.12/Appid/adnetworkanalytics/?metrics=['fb_ad_network_request','fb_ad_network_filled_request','fb_ad_network_imp','fb_ad_network_click','fb_ad_network_revenue']&breakdowns=['placement','country']&filters=$cityFilter&since=$sdata&until=$edata&access_token=AccessToken";

 

参考链接   https://developers.facebook.com/docs/audience-network/reporting-api