创建adset时参数无效

时间:2016-04-12 05:45:34

标签: php facebook sdk ads facebook-ads-api

在facebook-ads-sdk中创建Adset时,我得到的参数无效。我尽力跟踪并解决问题,但无法成功。请帮忙。以下是代码段:

   function adddSet($audienceid,$parentId,$accountId2,$campaignid,$productSetId){
    try {
        $adset = new AdSet(null, $accountId2);

        $adset->setData(array(
                AdSetFields::NAME => 'test',
                AdSetFields::DAILY_BUDGET =>40000,
                AdSetFields::BID_AMOUNT =>4000,
                AdSetFields::BILLING_EVENT => BillingEvents::IMPRESSIONS,
                AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::APP_INSTALLS,
                AdSetFields::CAMPAIGN_ID => $campaignid,                    
                AdSetFields::START_TIME => '2016-04-11T09:22:03+00:00',
                AdSetFields::END_TIME =>'2016-04-20T09:22:03+00:00',
                AdSetFields::TARGETING => (new TargetingSpecs())->setData(array(
                        TargetingSpecsFields::GEO_LOCATIONS => array(
                          'countries' => array('JP'),
                          'regions' => array(array('key' => '3886')),
                          'cities' => array(
                            array(
                              'key' => '2420605',
                              'radius' => 10,
                              'distance_unit' => 'mile',
                            ),
                          ),
                        ),
                        TargetingSpecsFields::GENDERS => array(1),
                        TargetingSpecsFields::AGE_MIN => 20,
                        TargetingSpecsFields::AGE_MAX => 24,
                        TargetingSpecsFields::PAGE_TYPES => array(
                          PageTypes::MOBILE_FEED,
                          PageTypes::MOBILE_EXTERNAL,
                        ),
                      )),
                  ));

        $adset->create(array(AdSet::STATUS_PARAM_NAME=>AdSet::STATUS_PAUSED));
    }
    catch(\FacebookAds\Http\Exception\RequestException $e){
        echo $e->getMessage();

    }
}

并得到以下回复:

参数无效

1 个答案:

答案 0 :(得分:0)

这可以帮助您更好地理解确切的错误。

function adddSet($audienceid,$parentId,$accountId2,$campaignid,$productSetId){
    try {
        $adset = new AdSet(null, $accountId2);

        $adset->setData(array(
                AdSetFields::NAME => 'test',
                AdSetFields::DAILY_BUDGET =>40000,
                AdSetFields::BID_AMOUNT =>4000,
                AdSetFields::BILLING_EVENT => BillingEvents::IMPRESSIONS,
                AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::APP_INSTALLS,
                AdSetFields::CAMPAIGN_ID => $campaignid,                    
                AdSetFields::START_TIME => '2016-04-11T09:22:03+00:00',
                AdSetFields::END_TIME =>'2016-04-20T09:22:03+00:00',
                AdSetFields::TARGETING => (new TargetingSpecs())->setData(array(
                        TargetingSpecsFields::GEO_LOCATIONS => array(
                          'countries' => array('JP'),
                          'regions' => array(array('key' => '3886')),
                          'cities' => array(
                            array(
                              'key' => '2420605',
                              'radius' => 10,
                              'distance_unit' => 'mile',
                            ),
                          ),
                        ),
                        TargetingSpecsFields::GENDERS => array(1),
                        TargetingSpecsFields::AGE_MIN => 20,
                        TargetingSpecsFields::AGE_MAX => 24,
                        TargetingSpecsFields::PAGE_TYPES => array(
                          PageTypes::MOBILE_FEED,
                          PageTypes::MOBILE_EXTERNAL,
                        ),
                      )),
                  ));

        $adset->create(array(AdSet::STATUS_PARAM_NAME=>AdSet::STATUS_PAUSED));
    }
    catch(\FacebookAds\Http\Exception\AuthorizationException $e){
        print_r($e->getResponse()->getBody());

    }
}