简体   繁体   English

如何获取 Facebook Lead Ads API 中的表单字段?

[英]How to get form fields in Facebook Lead Ads API?

I'm using Facebook Lead Ads API. I need to retrieve all fields from a form by ID.我正在使用 Facebook Lead Ads API。我需要通过 ID 从表单中检索所有字段。 I know I can:我知道我可以:

  • get all forms by calling /<PAGE_ID>/leadgen_forms , but it doesn't return the fields通过调用/<PAGE_ID>/leadgen_forms获取所有 forms,但它不返回字段
  • get a form by /<FORM_ID> , but it displays only the name and a few data, but not fields通过/<FORM_ID>获取表单,但它只显示名称和一些数据,但不显示字段
  • get all leads by /<FORM_ID>/leads - it gives me the fields in each lead, but only if I have leads;通过/<FORM_ID>/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?有没有专门的方法来检索潜在客户表单字段,即使还没有潜在客户?

I found out that I can download the CSV and in the first row, it gives me all fields IDs (and some other columns).我发现我可以下载 CSV 并且在第一行中,它为我提供了所有字段 ID(以及其他一些列)。 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.我不确定如何在 PHP 中读取此文件的内容,因为当我尝试在其上使用get_file_contents()时,它给了我一些 HTML。

You can get these by adding non-default field qualifiers , so the url becomes /<form_id>?fields=id,name,qualifiers .您可以通过添加非默认字段qualifiers来获得这些,因此 url 变为/<form_id>?fields=id,name,qualifiers

I haven't found it anywhere in the official docs though.不过,我在官方文档中的任何地方都没有找到它。 But it is quite common for new FB features to be poorly documented.但是新的 FB 功能记录不全是很常见的。

Example output示例输出

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

Just a warning since this answer comes first on google search.只是一个警告,因为这个答案首先出现在谷歌搜索上。

Since Facebook API v5.0 field "qualifiers" is removed and will throw an error.由于 Facebook API v5.0 字段“限定符”已被删除,并且会引发错误。

Replace it with "questions" which is similar (if not exact) syntax as qualifiers.将其替换为与限定符类似(如果不准确)语法的“问题”。 Found out the hard way on production server...在生产服务器上找到了困难的方法......

How do we suppose to get lead through form-id or ad-group-id?我们如何假设通过 form-id 或 ad-group-id 获得潜在客户?

First of all, to find those id is a problem as we are introduced to FB API first time.首先,找到那些id是一个问题,因为我们是第一次介绍FB API。 No Fb doc has this information how to get these ID or may some terminology issue to find these id.没有 Facebook 文档提供如何获取这些 ID 的信息,或者可能会遇到一些术语问题来查找这些 ID。 Not sure how to get these ids.不确定如何获取这些 ID。 any one know about this?任何人都知道这一点?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM