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
, but it doesn't return the fields/<FORM_ID>
, but it displays only the name and a few
data, but not fields/<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 randomIs there any dedicated way to retrieve leadgen form fields, even when there are no leads yet?
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.
To access your leads, you have to: Navigate to your Facebook page and click on the Publishing Tools button. On the left-hand side, you will see the Lead Ads Forms section. From here, click on the Forms Library option.
The leads data that is submitted through your Instant Form can be downloaded via a CSV export from Ads Manager. You can also download your leads from your Facebook Page, through the Faceboook API or access them through an integrated CRM system.
Export Leads from your Facebook Publishing ToolsAccess the Facebook Page that has your desired leads. On your Manage Page sidebar, scroll down to Publishing Tools. On the new sidebar, click Forms Library. Locate your desired form on the table and click Download under the Leads column.
You can get these by adding non-default field questions
, so the url becomes /<form_id>?fields=id,name,questions
.
The official docs don't describe the fields available for reading but the questions
field and its nested fields are described in the params used for creating a lead form.
Example output
{
"id": "1234567890000",
"name": "test form",
"questions": [
{
"key": "name",
"label": "Full Name",
"type": "FULL_NAME",
"id": "777888999000111"
},
{
"key": "email",
"label": "Email Address",
"type": "EMAIL",
"id": "111222333444555"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With