2017-11-25 305 views
0

我复制一模一样的简单例子铅表单创建的Facebook (https://developers.facebook.com/docs/marketing-api/guides/lead-ads/create首席营销形式APi的Facebook的创建错误

我使用的API SDK PHP运行$ form.create后() ;我收到这个错误..

致命错误:未捕获FacebookAds \ Http \ Exception \ AuthorizationException:(#100)在C:\ inetpub \ wwwroot \ leads \ vendor中需要参数questions [0] [type] \ facebook \ php-ads-sdk \ src \ FacebookAds \ Http \ Exception \ RequestException.php:

这是函数代码。

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最近使用成功的代码创建。

任何想法?提前致谢!

我debuged直到API:调用和倾倒这个$数据(befor呼叫)

阵列([名称] => AGENT-TIME_STAMP-标题[follow_up_action_url] =>https://www.site.es/ [问题] =>数组([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] => 5] => datetime [6] => float))))[context_card_id] => 1120914681377 165 legal_content_id] => 1166716330131814)

回答

0

,而不是LeadgenQuestionFields::TYPE => 'EMAIL'

试试这个'type' => 'EMAIL'

+0

LeadgenFormFields ::质询=>数组( (新LeadGenQuestion()) - >使用setData(阵列( \t \t '类型'=> '电子邮件', // LeadgenQuestionFields :: TYPE => '电子邮件',\t )), –

+0

同样的错误重现... –

1

解决了感谢musashii!

LeadgenFormFields ::质询=>数组(阵列( '类型'=> 'EMAIL')),

+0

真好!高兴你得到它的工作。 – musashii