【问题标题】:Upload email list to Facebook via API通过 API 将电子邮件列表上传到 Facebook
【发布时间】:2020-10-04 19:54:20
【问题描述】:

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

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

您对如何实现它有什么建议吗? 另外“我可以将电子邮件 ID 传递到此列表”下面的代码中的字段 = [] 吗? “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,
    ))

【问题讨论】:

    标签: facebook facebook-graph-api facebook-ads-api facebook-marketing-api facebook-python-business-sdk


    【解决方案1】:

    您应该首先像您已经做的那样创建自定义受众,然后您可以使用 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
    

    另请参阅SDK Doc TestCase here

    【讨论】:

      猜你喜欢
      • 2019-04-24
      • 1970-01-01
      • 2017-06-05
      • 2018-07-13
      • 2015-12-29
      • 1970-01-01
      • 2015-12-18
      • 2021-04-16
      • 2016-05-17
      相关资源
      最近更新 更多