首页 > 解决方案 > Facebook 赞助信息广告创意 | Java SDK

问题描述

我目前正在尝试使用 Facebook Java SDK 来创建 Facebook 广告/广告创意。到目前为止,这是我的代码:

        AdCreative adCreative = new AdAccount(id, context).createAdCreative()
                .setActorId("15726030300")
                .setObjectId("15726030300")
                .setName("Temp")
                .setMessengerSponsoredMessage("{\"message\":{\"attachment\":{\"type\":\"template\",\"payload\":{\"template_type\":\"generic\",\"elements\":[{\"title\":\"Title\",\"image_url\":\"https://image.ibb.co/bz5t6Q/placeholder.png\",\"subtitle\":\"Subtitle\",\"buttons\":[{\"type\":\"web_url\",\"url\":\"https://www.google.com/\",\"title\":\"View Website\"}]}]}}}}")
                .execute();

        new AdAccount(id, context).createAd()
                .setName("Hunter Test Ad")
                .setAdsetId("6229867441719")
                .setCreative(adCreative)
                .setStatus(Ad.EnumStatus.VALUE_PAUSED)
                .execute();

.setMessengerSponsoredMessage中,我包含了一些直接从 FB 示例复制的消息 JSON。这是格式化的 JSON:

{
    "message": {
        "attachment": {
            "type": "template",
            "payload": {
                "template_type": "generic",
                "elements": [
                    {
                        "title": "Title",
                        "image_url": "https://image.ibb.co/bz5t6Q/placeholder.png",
                        "subtitle": "Subtitle",
                        "buttons": [
                            {
                                "type": "web_url",
                                "url": "https://www.google.com/",
                                "title": "View Website"
                            }
                        ]
                    }
                ]
            }
        }
    }
}

我目前被抛出此错误:

{
  "error": {
    "message": "Invalid parameter",
    "type": "OAuthException",
    "code": 100,
    "error_subcode": 1815790,
    "is_transient": false,
    "error_user_title": "Invalid Attachment For Sponsored Message",
    "error_user_msg": "The message object for sponsored messages is invalid",
    "fbtrace_id": "AIjSPu5k0Z6Q_9VjvDv2mHx"
  }
}

当我尝试在他们的原生 AD 工具中使用 JSON 时,它似乎没有问题。但是,当我在此广告素材中使用它时,它不是。

如果我的信息可能结构正确,我需要帮助理解为什么会这样……

标签: javafacebooksdk

解决方案


推荐阅读