dounai7148 2016-10-25 23:23
浏览 79

Facebook Ads API - 必需的父ID

I am getting an error when trying to create an ad on Facebook through the PHP API.

Exception in AbstractCrudObject.php line 113: A parent ID is required.

The thing is, I copied the code from https://developers.facebook.com/docs/marketing-api/guides/lead-ads/create/v2.8 and just modified it to match what I need. I am confused as to what is missing, since I can't find something on this thus far through the documentation. Anyone else have the same issue or find out how to fix it?

Here is my code:

$link_data = new AdCreativeLinkData();
$link_data->setData([
    AdCreativeLinkDataFields::LINK => $creativeInfo->link,
    AdCreativeLinkDataFields::MESSAGE => $creativeInfo->message,
    AdCreativeLinkDataFields::IMAGE_HASH => $image->{AdImageFields::HASH}.PHP_EOL,
    AdCreativeLinkDataFields::CAPTION => $creativeInfo->caption,
    AdCreativeLinkDataFields::DESCRIPTION => $creativeInfo->description,
    AdCreativeLinkDataFields::CALL_TO_ACTION => [
        'type' => $creativeInfo->cta,
        'value' => [
            'lead_gen_form_id' => $creativeInfo->leadform,
        ],
    ],
]);

$story = new AdCreativeObjectStorySpec();
$story->setData([
    AdCreativeObjectStorySpecFields::PAGE_ID => $creativeInfo->page_id,
    AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
]);

$creative = new AdCreative();
$creative->setData([
    AdCreativeFields::OBJECT_STORY_SPEC => $story,
]);
$creative->create();
  • 写回答

2条回答 默认 最新

  • drslez4322 2016-11-16 16:42
    关注

    When you instantiate an AdCreative object you have to provide the ad account ID the Creative is on, like this:

    $creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>'); //i.e. act_12424141412
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果