如何获取Facebook Lead Ads API中的表单字段? [英] How to get form fields in Facebook Lead Ads API?

查看:238
本文介绍了如何获取Facebook Lead Ads API中的表单字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook Lead Ads API。我需要通过ID从表单中检索所有字段。我知道我可以:

I'm using Facebook Lead Ads API. I need to retrieve all fields from a form by ID. I know I can:


  • 通过调用 /< PAGE_ID> / leadgen_forms ,但它不返回字段

  • 通过 /< FORM_ID> 获取表单,但它只显示名称和一些
    数据,但不是字段

  • 通过 /< FORM_ID> / lead 获取所有潜在客户给我每个
    领域的领域,但只有我有领导;这个解决方案还有另一个问题 - 字段的顺序是随机的。

  • get all forms by calling /<PAGE_ID>/leadgen_forms, but it doesn't return the fields
  • get a form by /<FORM_ID>, but it displays only the name and a few data, but not fields
  • get all leads by /<FORM_ID>/leads - it gives me the fields in each lead, but only if I have leads; there's also another problem with this solution - the order of the fields is random

有没有专门的方式来检索领导表单字段,甚至当没有潜在客户?

Is there any dedicated way to retrieve leadgen form fields, even when there are no leads yet?

我发现我可以下载CSV,在第一行,它给我所有字段ID(和其他一些列)。我不知道如何在PHP中阅读此文件的内容,因为当我尝试使用 get_file_contents()时,它会给我一些HTML。 p>

I found out that I can download the CSV and in the first row, it gives me all fields IDs (and some other columns). I'm not sure though how I can read the content of this file in PHP, because it gives me some HTML when I try to use get_file_contents() on it.

推荐答案

您可以通过添加非默认字段限定符 url变成 /< form_id>?fields = id,name,qualifiers

You can get these by adding non-default field qualifiers, so the url becomes /<form_id>?fields=id,name,qualifiers.

我没有在官方文档中的任何地方找到它。但是对于新的FB功能来说,这是很常见的。

I haven't found it anywhere in the official docs though. But it is quite common for new FB features to be poorly documented.

示例输出

{
  "id": "1234567890000",
  "name": "test form",
  "qualifiers": [
    {
      "field_key": "first_name",
      "label": "First Name",
      "question": "First name",
      "id": "777888999000111"
    },
    {
      "field_key": "last_name",
      "label": "Last Name",
      "question": "Last name",
      "id": "111222333444555"
    }
  ]
}

这篇关于如何获取Facebook Lead Ads API中的表单字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆