我正在尝试创建广告素材,但收到无效参数错误。异常甚至没有指明哪个参数是错误的。
try {
$link_data = new AdCreativeLinkData();
$link_data->setData(array(
AdCreativeLinkDataFields::MESSAGE => 'try it out',
AdCreativeLinkDataFields::LINK => 'http://www.google.com',
AdCreativeLinkDataFields::IMAGE_HASH => '704e55dbf724243acfb8457a4f68a92a',
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
));
$creative = new AdCreative(null, 'act_576834712392068');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative Suite CRM',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
$creative->create();
}
catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
捕获异常:异常 带有消息的“FacebookAds\Http\Exception\AuthorizationException” “参数无效”
您似乎还没有添加需要发布广告素材的页面。我认为在
AdCreativeObjectStorySpecFields::PAGE_ID => 'your published page id here'
中添加 object_story_spec array
可以解决您的问题。
不要忘记将应用程序的状态设置为开发中的活动状态。这也是同样失败的原因。您可以使用
更详细地检查您的错误catch (Exception $e) {
var_dump($e)
}