facebook-graph-api - Facebook Marketing API 展示位置资产自定义asset_feed_spec 错误
问题描述
我一直在尝试根据展示位置(facebook-feed、messenger-story)自动生成具有不同内容的广告。我一直在尝试遵循文档。
但是由于某种原因,它返回一个错误,指出整个 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)
]);
为了使其更具可读性,我创建了一个函数来创建不同的资产提要规范。要更好地理解它,请参阅文档中的示例。
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'
]
]
];
}
解决方案
要生成广告素材,您需要传递带有有效 page_id 的 object_story_spec,如下所示,
{
"object_story_spec": {
"page_id": "10506210208xxx"
},
"asset_feed_spec": {
"videos": [
{
"adlabels": [
{
"name": "placement_asset_3667064314xxx"
}
],
"video_id": "3667064314xxx"
},
..
它应该在提供有效的 page_id 后工作,它对我有用。
推荐阅读
- sql-server - 将行数据转换为动态列
- python-3.x - Python:如何打印一列具有固定宽度的字符串?
- sql - Postgres,将单行拆分为多行
- python - 在 Docker 上运行 Redis rq worker
- button - Python listwidget点击项目按钮
- php - 如何将文件夹和子文件夹中的所有文件放入数组中
- reactjs - React Native Navigation:检查抽屉是否打开
- wordpress - wp_get_attachment_image:手动填充“大小”属性的最佳方法?
- assembly - 从 XMM 迁移到 YMM
- powershell - 在使用 Start-Process "msiexec.exe" ... -wait 安装软件的过程中,如何修复错误并继续安装过程?