我一直在尝试根据位置自动生成不同内容的广告(facebook-feed,信使故事)。我一直在追踪文件。
但是由于某种原因,它返回一个错误,说明整个object_story_spec都是错误的。但这可能与我的asset_feed_spec有关,因为这是我唯一改变的东西。
object_story_spec param is invalid
Object story spec is ill formed. Maybe missing Page ID or creative details, or invalid fields exist
以前有人试过这样做吗?或者有什么方法可以让我得到更清晰的错误信息?
下面是我在尝试创建创意时使用的代码。
$creative->setData([
AdCreativeFields::CALL_TO_ACTION_TYPE => $callToAction,
AdCreativeFields::IMAGE_HASH => $image_hash,
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
AdCreativeFields::ASSET_FEED_SPEC => $this->getAssetFeedSpec($post_message, $link_url, $headline, $image_hash, $description)
]);
为了提高它的可读性,我创建了一个函数来创建不同的Asset规范。要更好地理解它,请参阅文档中的示例。
public function getAssetFeedSpec($post_message, $link_url, $headline, $image_hash, $description) {
return [
'images' => [
[
'hash' => $image_hash
]
],
'bodies' => [
[
'adlabels' => [
[
'name' => 'labelfirst',
]
],
'text' => $post_message
],
[
'adlabels' => [
[
'name' => 'labelsecond',
]
],
'text' => $headline
]
],
'titles' => [
[
'text' => $headline
]
],
'descriptions' => [
[
'text' => $description
]
],
'ad_formats' => [
'SINGLE_IMAGE'
],
'call_to_action_types' => [
'LEARN_MORE'
],
'link_urls' => [
[
'website_url' => $link_url
]
],
'videos' => [],
'asset_customization_rules' => $this->getAssetCustomizationRules()
];
}
我还分离了asset_customization_rules,以使这一点更容易理解。
public function getAssetCustomizationRules() {
return [
[
'customization_spec' => [
'publisher_platforms' => [
'facebook',
'instagram',
'audience_network',
'messenger'
],
'facebook_positions' => [
'feed',
],
'instagram_positions' => [
'stream'
],
'audience_network_positions' => [
'classic'
]
],
'body_label' => [
'name' => 'labelfirst'
]
],
[
'customization_spec' => [
'publisher_platforms' => [
'messenger'
],
'messenger_positions' => [
'stream'
]
],
'body_label' => [
'name' => 'labelsecond'
]
]
];
}
发布于 2022-01-27 10:06:50
要产生创造性,您需要使用有效的object_story_spec传递page_id,如下所示,
{
"object_story_spec": {
"page_id": "10506210208xxx"
},
"asset_feed_spec": {
"videos": [
{
"adlabels": [
{
"name": "placement_asset_3667064314xxx"
}
],
"video_id": "3667064314xxx"
},
..
它应该在提供了一个有效的page_id之后才能工作,它对我是有效的。
https://stackoverflow.com/questions/67773042
复制相似问题