Пример #1
0
def add_users_mk(ca_id, users):
    FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
    audience = CustomAudience(ca_id)

    schema = [
        CustomAudience.Schema.MultiKeySchema.email,
    ]

    audience.add_users(schema, users, is_raw=True)
    return audience.get_id()
Пример #2
0
def create_lookalike_audience(name: str, spec: Dict[str, Any],
                              source: CustomAudience) -> Instruction:

    params = {
        CustomAudience.Field.name: name,
        CustomAudience.Field.subtype: CustomAudience.Subtype.lookalike,
        CustomAudience.Field.origin_audience_id: source.get_id(),
        CustomAudience.Field.lookalike_spec: json.dumps(spec),
    }

    return Instruction("custom_audience", "create", params, None)
def add_users_mk(ca_id, users):
    FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
    audience = CustomAudience(ca_id)
    audience_to_query = list()
    used_ids = list()

    for line in users:
        contact_id, aud_name, email, phone, used = line
        audience_to_query.append([email, phone])
        used_ids.append(contact_id)

    schema = [
        CustomAudience.Schema.MultiKeySchema.email,
        CustomAudience.Schema.MultiKeySchema.phone
    ]

    audience.add_users(schema, audience_to_query, is_raw=True, pre_hashed=True)
    print(used_ids)
    return audience.get_id()
Пример #4
0
def add_users_mk(ca_id, name, users):
    try:
        FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
        audience = CustomAudience(ca_id)
        audience_to_query = list()

        for line in users:
            if line[0].strip() == name.strip():
                aud_name, email, phone = line
                audience_to_query.append([email, phone])

        schema = [
            CustomAudience.Schema.MultiKeySchema.email,
            CustomAudience.Schema.MultiKeySchema.phone
        ]

        audience.add_users(schema, audience_to_query, is_raw=True)
        return audience.get_id()
    except Exception as e:
        print(type(e))