在 Facebook 营销中创建 AdSet 时缺少目标受众位置错误 API

Missing Target Audience Location Error when creating AdSet in Facebook Marketing API

我正在使用 NodeJS SDK 创建广告系列、上传广告素材,然后创建 AdSet 和广告。

在创建 AdSet 时,我 运行 遇到了配置我的目标对象的问题。

考虑以下因素:

  const targeting = new Targeting();
  targeting[Targeting.Fields.countries] = ['US'];
  targeting[Targeting.Fields.country] = 'US';

为我的广告集使用此定位时,出现以下错误:

"name": "FacebookRequestError",
  "message": "Missing Target Audience Location: Your audience is missing a location. You can add a location or a Custom Audience.",
  "status": 400,
  "response": {
    "error": {
      "message": "Invalid parameter",
      "type": "OAuthException",
      "code": 100,
      "error_data": {
        "blame_field_specs": [
          [
            "targeting"
          ]
        ]
      },
      "error_subcode": 1885364,
      "is_transient": false,
      "error_user_title": "Missing Target Audience Location",
      "error_user_msg": "Your audience is missing a location. You can add a location or a Custom Audience.",
    }
  },

如果我尝试这样填写字段 geo_locations

targeting[Targeting.Fields.geo_locations] = { countries: ['US'] };

我收到以下错误:

"name": "FacebookRequestError",
  "message": "Invalid Targeting Spec: The specified targeting spec is not valid because: The field _data is not a valid target spec field",
  "status": 400,
  "response": {
    "error": {
      "message": "Invalid parameter",
      "type": "OAuthException",
      "code": 100,
      "error_data": "null",
      "error_subcode": 1487079,
      "is_transient": false,
      "error_user_title": "Invalid Targeting Spec",
      "error_user_msg": "The specified targeting spec is not valid because: The field _data is not a valid target spec field",
    }
  },

阅读文档、源代码和 Internet 上的示例后,我不明白我应该如何解决此问题并正确设置此 AdSet 的定位

我意识到关于 TargetingAdSet 对象关系的文档是错误的。 它说 here 创建一个 Targeting 对象并将其传递给 PHP 和 JAVA SDK 的 AdSet 对象,例如

$adset->setData(array(
  AdSetFields::NAME => 'My AdSet',
  AdSetFields::TARGETING => (new Targeting())->setData(array(
    TargetingFields::GEO_LOCATIONS => array(
      'countries' => array(
        'US',
      ),
    ),
  )),
));

我可以通过简单地执行此操作而不是使用提供的 SDK class Targeting

来解决问题
  const targeting = {
    geo_locations: {
      countries: ['US'],
    },
  };

  const adSet = new AdSet(accountId);
  adSet[AdSet.Fields.targeting] = targeting;
  adSet[AdSet.Fields.name] = 'Test Ad Set';

要么文档应该有一个 NodeJS 示例,要么 SDK 已经损坏并且应该被修复。