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 FacebookAds\Http\Exception\AuthorizationException: (#100) The parameter questions[0][type] is required in C:\inetpub\wwwroot\leads\vendor\facebook\php-ads-sdk\src\FacebookAds\Http\Exception\RequestException.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] => FacebookAds\Object\LeadGenQuestion Object ( [data:protected] => Array ( [key] => [label] => [options] => [type] => EMAIL ) [_type_checker:protected] => FacebookAds\TypeChecker Object ( [type_data:FacebookAds\TypeChecker:private] => Array ( [key] => string [label] => string [options] => list [type] => string ) [enum_data:FacebookAds\TypeChecker:private] => Array ( ) [primitive_types:FacebookAds\TypeChecker: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 )