How to get form fields in the API for personal ads?

I use the Facebook Ads API. I need to get all fields from a form by id. I know that I can:

  • get all forms by calling /<PAGE_ID>/leadgen_formsbut it doesn't return fields
  • get the form /<FORM_ID>, but it displays only the name and some data, but not the fields
  • get all the conclusions /<FORM_ID>/leads- he gives me the fields in every lead, but only if I have leadership; there is another problem with this solution - the order of the fields is random

Is there any dedicated way to get input form fields, even if there are no links yet?

I found out that I can load CSV in the first row too, it gives me all field identifiers (and some other columns). I am not sure though, how can I read the contents of this file in PHP because it gives me some HTML when I try to use get_file_contents()it.

+4
source share
1 answer

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

I did not find it anywhere in the official docs. But for new FB features, poor documentation is pretty common.

Output example

{
  "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"
    }
  ]
}
+14
source

All Articles