使用Facebook API创建Lookalike受众

时间:2017-09-27 10:11:18

标签: c# .net facebook facebook-graph-api

我想使用Facebook API创建一个Lookalike Audience。这是我的代码:

public override SocialAudience CreateCustomAudience(SocialAudience SAudience)
{
    string access_token = GetAccessToken(SAudience.AdAccount.FacebookUser);
    FC.AccessToken = access_token;
    dynamic PostParam = new ExpandoObject();
    PostParam.name = SAudience.Audience.Name;
    if (!string.IsNullOrEmpty(SAudience.Audience.Description))
        PostParam.description = SAudience.Audience.Description;
    dynamic Result = null;
    if (string.IsNullOrEmpty(SAudience.Social_ID))
    {
        PostParam.subtype = SAudience.Type;
        if (SAudience.Type.ToUpper() == "LOOKALIKE")
        {
            PostParam.origin_audience_id = SAudience.origin_audience_id;
            PostParam.lookalike_spec = "{ starting_ratio: \"0\", ratio: \"0.01\", location_spec: { geo_locations: { countries: ['UK'] } } }";
        }                
        Result = FC.Post(string.Format("/{0}/customaudiences?fields=id,approximate_count,delivery_status,operation_status", SAudience.AdAccount.Social_ID), PostParam);
        SAudience.Social_ID = Result.id;
    }
    else
        Result = FC.Post(string.Format("/{0}?fields=id,approximate_count,delivery_status,operation_status", SAudience.Social_ID), PostParam);

    SAudience.delivery_status_Description = Result.delivery_status.description;
    SAudience.delivery_status = Result.delivery_status.code.ToString();
    SAudience.Size = Result.approximate_count;
    SAudience.Availability = Result.operation_status.description;
    return SAudience;
}

此方法创建为受众,自定义和类似的类型。当我尝试用这段代码创建一个相似的观众时,我收到一个错误:

  

(#2654)找不到有效地点:请在地址中添加有效地点   位置规范。

我改变了这部分代码:

PostParam.lookalike_spec = "{ starting_ratio: \"0\", ratio: \"0.01\", location_spec: { geo_locations: { countries: ['UK'] } } }";

由:

PostParam.lookalike_spec = "{ type: \"reach\", country: \"UK\" }";

我收到此错误:

  

(#2654)不支持在英国国家/地区创建相似的受众群体   因为活跃的用户数量太小

注意:我使用尺寸为900的自定义受众群体。

请帮助。

1 个答案:

答案 0 :(得分:0)

我犯了一个错误。我不应该使用英国代码来选择英国人。正确的代码是GB。