如何解决通过API将电子邮件列表上传到Facebook
我需要发送或创建用户电子邮件列表作为受众群体列表到我们的业务Facebook帐户,以便我们可以将其用于营销目的(我正在使用Python 3.8)。
下面是我从Google获得的代码,但是当我搜索时发现我无法直接通过API将电子邮件传递给Facebook。
您对此有何建议? 在下面的代码中,“我是否可以将电子邮件ID传递到此列表”字段= []? AND“ ID”是什么意思?
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会为您完成)。例如:
custom_audience = CustomAudience(DocsDataStore.get('ca_id'))
response = custom_audience.add_users(
schema=CustomAudience.Schema.email_hash,users=[
'joe@example.com',]
)
如果您看一下SDK DOC Here:
CustomAudience.add_users (schema,users,is_raw,app_ids,pre_hashed)
pre_hashed: Whether or not the data has already been hashed. If not,the SDK will automatically hash the data
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。