2017-11-25 10 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