0

我正在使用 Facebook Marketing API 构建一些广告自动化平台。现在我正在尝试执行广告创建。最后一步之一是设置负责广告展示的广告创意对象。这是我的代码:

public function createCreative() {
        $link_data = new LinkData();
        $link_data->setData(array(
            LinkDataFields::MESSAGE => 'try it out',
            LinkDataFields::LINK => 'http://nomer.beeline.kz/ru/Numbers?utm_source=fb&utm_medium=cpc&utm_campaign=010681',
            LinkDataFields::CAPTION => 'My caption',
            LinkDataFields::IMAGE_HASH => 'aaf5226d9a8121e0dd30670565f00005',
        ));

        $object_story_spec = new ObjectStorySpec();
                $object_story_spec->setData(array(
                    ObjectStorySpecFields::LINK_DATA => $link_data,
                    ObjectStorySpecFields::PAGE_ID => 178928252129734
        ));

        $creative = new AdCreative(null, 'act_'.$this->account_id);

        $creative->setData(array(
            AdCreativeFields::NAME => 'Sample Creative',
            AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
        ));

        $creative->create();

执行后我得到这个错误:

FacebookAds\Http\Exception\RequestException

无效的参数

我认为它是PAGE_ID参数,实际上我不知道应该在那里。我粘贴了ID我的公共页面,所有广告操作都在其中发生。有任何想法吗?

4

1 回答 1

0

PAGE_ID参数正确。实际上问题在于 $link_data你失踪的地方CALL_TO_ACTION

$link_data = new LinkData();
$link_data->setData(array(
  LinkDataFields::MESSAGE => 'try it out',
  LinkDataFields::LINK => '<URL>',
  LinkDataFields::CAPTION => 'My caption',
  LinkDataFields::CALL_TO_ACTION => array(
    'type' => CallToActionTypes::SIGN_UP,
    'value' => array(
      'link' => '<URL>',
      'link_caption' => 'Sign up!',
    ),
  ),
));

$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(
  ObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
  ObjectStorySpecFields::LINK_DATA => $link_data,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
  AdCreativeFields::NAME => 'Sample Creative',
  AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));

$creative->create();

Facebook 营销 API 文档广告创意链接数据

于 2016-06-09T05:43:51.503 回答