Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
Get all lead ads form facebook API

I am trying to get all lead generation forms in my PHP script using Facebook API version 9.0

I am making the request like this:

https://graph.facebook.com/v9.0/<PAGE_ID>/leadgen_forms?<access_token>

But its returning error, saying

{
   "error": {
      "message": "(#12) leadgen_forms field is deprecated for versions v5.0 and higher",
      "type": "OAuthException",
      "code": 12,
      "fbtrace_id": "ARMp3WCko2raN5521458h"
   }
}

If I change the version in the above request, it says:

You are calling a deprecated version of the Ads API. Please update to the latest version: v9.0.

UPDATE:

Here's the SDK function which i am using to get Lead Generation Forms:

public function getLeadGenForms(array $fields = array('first_name', 'last_name'), array $params = array(), $pending = false) {
    $this->assureId();

    $param_types = array(
      'query' => 'string',
    );
    $enums = array(
    );

    $request = new ApiRequest(
      $this->api,
      $this->data['id'],
      RequestInterface::METHOD_GET,
      '/leadgen_forms',
      new LeadgenForm(),
      'EDGE',
      LeadgenForm::getFieldsEnum()->getValues(),
      new TypeChecker($param_types, $enums)
    );
    $request->addParams($params);
    $request->addFields($fields);
    return $pending ? $request : $request->execute();
  }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is the correct GET request URL:

https://graph.facebook.com/v9.0/<PAGE_ID>/leadgen_forms?access_token=<page_access_token>

And example use of the FB PHP SDK:

try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/<PAGE_ID>/leadgen_forms',
    '{access-token}'
  );
} catch(FacebookExceptionsFacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(FacebookExceptionsFacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();

Source: Generated from the Graph API Explorer.

Screenshot of a working error-free response: enter image description here

Requirements:

  • Use the page access token of the page <PAGE_ID> (not your own user token or any other page).
  • Grant the pages_show_list, pages_read_engagement and pages_manage_ads permissions to the FB app that you connect to (to get the page access token).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda