通过FB Marketing API创建AdSet

时间:2017-01-08 18:50:25

标签: php facebook api

我正在尝试通过FB Marketng API创建AdSet,但收到错误100(无效参数)。我甚至尝试从FB Developers Docs粘贴示例代码,但它是相同的错误。请帮忙。 这是我的代码:

use FacebookAds\Object\Targeting;
use FacebookAds\Object\Fields\TargetingFields;

$targeting = new Targeting();
$targeting->{TargetingFields::GEO_LOCATIONS} =
  array(
    'countries' => array('US')
  );


/**
 * Step 4 Create the AdSet
 */
use FacebookAds\Object\AdSet;

use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;

try{
    $start_time = (new \DateTime("+1 week"))->format(DateTime::ISO8601);
    $end_time = (new \DateTime("+2 week"))->format(DateTime::ISO8601);
    $adset = new AdSet(null, $account_id);
    $adset->setData(array(
        AdSetFields::NAME => 'Adslondon1',
        AdSetFields::CAMPAIGN_ID => '6070381098103',
        AdSetFields::LIFETIME_BUDGET => '50',
        AdSetFields::TARGETING => $targeting,
        AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::LINK_CLICKS,
        AdSetFields::BILLING_EVENT => AdSetBillingEventValues::LINK_CLICKS,
        AdSetFields::BID_AMOUNT => '10',
        AdSetFields::START_TIME => $start_time,
        AdSetFields::END_TIME => $end_time

    ));

    $adset->create(array(
        AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
    ));

    echo 'AdSet  ID: '. $adset->id . "\n";
}

0 个答案:

没有答案