0

我正在尝试过滤我们通过此端点获得的 Facebook 自定义受众:

var url = $"{advertiserId}/customaudiences?limit={limit}&fields=name" 
                  + "&filtering=[{'field':'subtype','operator':'EQUAL', 'value':'CUSTOM'}]";

上述调用有效并返回用户自定义受众。但是,我还需要通过 data_source.type 和 data-source.subtype 过滤自定义受众,即

filtering=[...{'field':'data_source.type','operator':'EQUAL', 'value':'FILE_IMPORTED'}]";

我已经阅读了文档,但看不到我哪里出错了。

我得到一个

无效的参数

尝试按 data_source.type 过滤时出错

这是我看过的文档:

https://developers.facebook.com/docs/marketing-api/reference/ad-account/customaudiences/

https://developers.facebook.com/docs/marketing-api/reference/custom-audience/#parameters-2

4

1 回答 1

1

我设法通过将 data_souce 添加到我的请求 URL 并使用我创建并存储在配置中的列表对 data_source 进行过滤来解决此问题:

public FacebookEntitiesResult<FacebookAudience> GetFacebookAudiences(string advertiserId, string token, int? limit, PagingCursors cursors)
    {
        if (!limit.HasValue)
            limit = ConfigValues.FacebookGraphResultLimit;

        var url = $"{advertiserId}/customaudiences?limit={limit}&fields=name,data_source"
                  + "&filtering=[{'field':'subtype','operator':'EQUAL', 'value':'CUSTOM'}]";

        var customAudienceTypes = Instance.Of<IConfigHelper>().GetStringArrayOfAppSettings(ConfigKeys.Extensions.FacebookAudienceUnsupportedTypeArray, ",");

        var customAudiences = GetResult<FacebookEntitiesResult<FacebookAudience>>(url, token, cursors);
        customAudiences.Data = customAudiences.Data.Where(a => !customAudienceTypes.Contains(a.Data_Source.Type)).ToArray();

        return customAudiences;
    }

配置:

<key name="FacebookAudienceUnsupportedTypeArray" defaultValue="THIRD_PARTY_IMPORTED"></key>
于 2021-10-05T14:37:15.030 回答