skip to Main Content

I’m reproducing exactly the same simple example for lead form creation on facebook
(https://developers.facebook.com/docs/marketing-api/guides/lead-ads/create)

I’m using the API SDK PHP and after running $form.create(); i’m recibing this error..

Fatal error: Uncaught FacebookAdsHttpExceptionAuthorizationException: (#100) The parameter questions[0][type] is required in C:inetpubwwwrootleadsvendorfacebookphp-ads-sdksrcFacebookAdsHttpExceptionRequestException.php:

This is the function code.

function create_form($page_id,$form_name,$url_follow,$idlegal,$idcontext){
  $form = new LeadgenForm(null, $page_id);
  $form->setData(array(
  LeadgenFormFields::NAME => $form_name,
  LeadgenFormFields::FOLLOW_UP_ACTION_URL => $url_follow,
  LeadgenFormFields::QUESTIONS => array(
      (new LeadGenQuestion())->setData(array(
         LeadgenQuestionFields::TYPE => 'EMAIL',
         )),
      ),
  'context_card_id' => $idcontext,
  'legal_content_id' => $idlegal,
));
$form->create();
}

$idcontext $idlegal are recently created with succesfully code.

Any Idea? thanks in advance!

I debuged until api:call and dumped this $data (befor call)

Array ( [name] => AGENT-TIME_STAMP-Title [follow_up_action_url] => https://www.site.es/ [questions] => Array ( [0] => FacebookAdsObjectLeadGenQuestion Object ( [data:protected] => Array ( [key] => [label] => [options] => [type] => EMAIL ) [_type_checker:protected] => FacebookAdsTypeChecker Object ( [type_data:FacebookAdsTypeChecker:private] => Array ( [key] => string [label] => string [options] => list [type] => string ) [enum_data:FacebookAdsTypeChecker:private] => Array ( ) [primitive_types:FacebookAdsTypeChecker:private] => Array ( [0] => unsigned int [1] => int [2] => bool [3] => string [4] => Object [5] => datetime [6] => float ) ) ) ) [context_card_id] => 1120914681377165 [legal_content_id] => 1166716330131814 )

2

Answers


  1. Chosen as BEST ANSWER

    Solved thanks to musashii!

    LeadgenFormFields::QUESTIONS => array(array('type' => 'EMAIL')),


  2. instead of LeadgenQuestionFields::TYPE => 'EMAIL'

    try this 'type' => 'EMAIL'

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search