You need to enable JavaScript to run this app. 如何使用Facebook Graph API批量拉取广告Insights数据
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Facebook Graph API批量拉取广告Insights数据

解决方案

你需要使用Facebook Marketing API的嵌套字段传参语法,将时间范围参数直接绑定到insights字段上,而不是作为全局参数传入,才能生效。

1. 使用date_preset指定时间范围的请求写法

直接在insights后追加.date_preset(参数值)即可,示例如下:

act_XXXXXXXXXXXXXXX/ads?fields=insights.date_preset(maximum){cpc, impressions}

除了maximum之外,其他你常用的date_preset取值(比如last_90d、this_month等)都可以用这个方式传入。

2. 自定义起止时间的请求写法

如果需要指定具体的时间区间,使用time_range参数传参即可,示例如下:

act_XXXXXXXXXXXXXXX/ads?fields=insights.time_range({"since":"2022-01-01","until":"2023-06-30"}){cpc, impressions}

注意事项

  • 若单条广告在你指定的时间范围内无投放数据,返回结果中对应的insights字段会是空数组,数据处理时需做好判空逻辑。
  • 全量拉取数据时建议在请求中添加limit参数限制单页返回的广告数量(比如limit=50),避免请求超时。

内容的提问来源于stack exchange,提问作者jeepers mcface

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.18 14:36:04