在Facebook Marketing API上进行多次过滤(日期范围,国家/地区,印象设备等)

问题描述 投票:2回答:1

我们希望根据多种过滤条件(日期范围,国家/地区,印象设备等)从Facebook Marketing API(Insights API-https://developers.facebook.com/docs/marketing-api/insights)中获取营销费用。

我一次可以应用1个过滤器,例如:

  • “国家”:GET https://graph.facebook.com/v3.1/act_<ACCOUNT_ID>/insights?access_token=<ACCESS_TOKEN>&fields=["spend"]&time_range={"since":"YYYY-MM-DD","until":"YYYY-MM-DD"}&filtering=[{"field":"country","operator":"EQUAL","value":"GB"}]

  • “ impression_device”:GET https://graph.facebook.com/v3.1/act_<ACCOUNT_ID>/insights?access_token=<ACCESS_TOKEN>&fields=["spend"]&time_range={"since":"YYYY-MM-DD","until":"YYYY-MM-DD"}&filtering=[{field:"impression_device","operator":"IN","value":["iphone","ipad"]}]

但是不能在一个查询中同时应用,而得到下一个响应:

{
"error": {
    "message": "Service temporarily unavailable",
    "type": "OAuthException",
    "is_transient": false,
    "code": 2,
    "error_subcode": 1504018,
    "error_user_title": "Your request timed out",
    "error_user_msg": "Please try a smaller date range, fetch less data, or use async jobs",
    "fbtrace_id": "ADKphoammbM"
  }
}

我还尝试将报告作为异步作业运行(通过发出POST请求(如此处所述-https://developers.facebook.com/docs/marketing-api/insights/best-practices/#asynchronous),作业已成功启动:

{
"id": "317371612321115",
"account_id": "<ACCOUNT_ID>",
"time_ref": 1545121794,
"async_status": "Job Started",
"async_percent_completion": 0,
"is_running": true,
"date_start": "2018-12-17",
"date_stop": "2018-12-17"
}

但随后出现“作业失败”状态:

{
"id": "317371612321115",
"account_id": "<ACCOUNT_ID>",
"time_ref": 1545121794,
"async_status": "Job Failed",
"async_percent_completion": 0,
"date_start": "2018-12-17",
"date_stop": "2018-12-17"
}

是否可以按照我下面的描述应用多个过滤器?是否存在一些限制或文档如何应用多个过滤器?谢谢。

facebook-graph-api facebook-marketing-api facebook-insights
1个回答
0
投票

您可以在同一请求中应用过滤器数组。试试:

© www.soinside.com 2019 - 2024. All rights reserved.