通过API将电子邮件列表上传到Facebook [英] Upload email list to Facebook via API

本文介绍了通过API将电子邮件列表上传到Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将用户电子邮件列表发送或创建为受众列表到我们的业务Facebook帐户,以便我们可以将其用于营销目的(我正在使用Python 3.8).

I need to send or create the list of user emails to our business facebook account as an audience list ,so that we can use it for our marketing purposes(I'm using Python 3.8).

下面是我从Google获得的代码,但是当我搜索时发现我无法直接通过API将电子邮件传递给Facebook.

Below is the code which i got from Google, But when i searched i found that we cannot directly pass the emails to Facebook via API.

您对实现它有什么建议吗?另外,我可以在下面的代码中将电子邮件ID传递到此列表"字段= []吗?并且"ID"是什么?是什么意思?

Do you have any suggestions on how to achieve it ? Also "can i pass email ID's to this list "fields = [] in the below code ? AND what does the "ID" means ?

  from facebook_business.adobjects.adaccount import AdAccount
    from facebook_business.adobjects.customaudience import CustomAudience
    from facebook_business.api import FacebookAdsApi
     
    
    access_token = 'EAAi0wZCiZxxxxxxxxxxxxxxxDZD'
    app_secret = 'xxxxxxxxxxxxxxx'
    app_id = 'xxxxxxxxxxx'
    id = '<ID>'

    fields = []
    FacebookAdsApi.init(access_token=access_token)
    print("Access succesful") 
    params = {
      'name': 'My new Custom Audience',
      'subtype': 'CUSTOM',
      'description': 'People who purchased on my website',
      'customer_file_source': 'USER_PROVIDED_ONLY',
    }
    print (AdAccount(id).create_custom_audience(
      fields=fields,
      params=params,
    ))

推荐答案

您应该像已经创建的那样先创建自定义受众,然后可以使用SDK API添加/删除电子邮件(您无需手动对电子邮件进行哈希处理:SDK会为您完成此操作).例如:

You should first create the Custom Audience like you already do, then you can add/remove emails with the SDK API (you do not need manually hash the email: the SDK will do it for you). As example:

custom_audience = CustomAudience(DocsDataStore.get('ca_id'))
        response = custom_audience.add_users(
            schema=CustomAudience.Schema.email_hash,
            users=[
                'joe@example.com',
            ]
        )

如果您查看另请参见SDK Doc TestCase在这里

这篇关于通过API将电子邮件列表上传到Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆