javascript - 使用 FB api 创建 Facebook 广告时未找到给定广告组的创意规范

标签 javascript json facebook-graph-api facebook-apps facebook-marketing-api

我有一个 Facebook 事件、广告集和一个使用 Facebook API 创建的广告。然而,当我尝试使用这三个端点(:我认为它们被称为端点)创建广告时,它给出了一个错误No creative spec found for given adgroup.这是我的使用先前创建的图片、广告集和事件创建广告的代码:

FB.api('act_xxxxxxxx/adcreatives', 'POST', {
name: 'My Testworthy Ad Creative',
title: 'Facebook Marketing Partners',
body: 'Get exactly the things you need from your marketing.',
image_url: 'img url',
object_url: 'https://www.facebookmarketingpartners.com',
access_token:'app access token for selected permissions'

        },function(adcreativeresponse){
          console.log(adcreativeresponse.id);
          FB.api('/act_xxxxxxxx/ads','POST',  {
          creative:["{\"creative_id\" : \"adcreativeresponse.id /*or a static creative_id*/\"}"],
          name:"tryncatch",
          adset_id:"adsetId",
          status:"PAUSED",
          access_token:"app access token with the required permissions selected"},
          function(response) {
                                console.log("response for ad");
                                                 console.log(response);// 
                                                 Insert your code here
                             }
                                            );

                                        } );

如代码所示,我创建了一个 adcreative,它返回创建的 adcreative 的节点 ID,我在 response 中使用它函数使用之前收集的所有参数创建一个 ad,但它给我一个错误,如记录 “response for ad” 后提供的图像所示。 enter image description here

我在这里遗漏了什么吗?

最佳答案

键的值 creative在你的参数对象中应该是:

"creative": {"creative_id":<CREATIVE_ID>} // without the array

正如 Facebook 官方文档中所述 creating ads :

creative (AdCreative):

This field is required for create. The ID of the ad creative to be used by this ad. You can read more about creatives here. You should supply the ID within an object as follows:

{"creative_id": <CREATIVE_ID>}

关于javascript - 使用 FB api 创建 Facebook 广告时未找到给定广告组的创意规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45795047/

相关文章:

javascript - 不使用 webconfig 或 htaccess 将网页重定向到新目录名称

javascript - 如何为响应式菜单的下拉设置动画?

php - 如何使用 FB Graph 在提要(墙上)上发布消息

iphone - Facebook iOS SDK 崩溃

javascript - facebook connect登录更麻烦(JS SDK)

javascript - 如何在javascript中创建get方法?

Javascript:返回包含其他函数的对象的函数?这个叫什么?

jquery - 将值与 jquery 中的 JSON 数组值相匹配

jquery - 何时使用 JavaScriptSerializer jquery ajax 和 asp.net 服务器端方法

javascript - 将属性从嵌套模型映射到 extjs 表单 View