0

我正在尝试找出如何替换自定义受众中的​​用户。我可以删除和创建新的受众,但理想情况下我只想更新现有的受众,因为它与其他帐户共享。

我想我可能可以使用create_users_replace但我收到错误消息:

facebook_business.exceptions.FacebookRequestError:

  Message: Call was not successful
  Method:  POST
  Path:    https://graph.facebook.com/v13.0/23850060704540982/usersreplace
  Params:  {}

  Status:  400
  Response:
    {
      "error": {
        "message": "(#100) The parameter session is required",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "AOJ9p0Hd1Kla4NRlkhOnHIQ"
      }
    }

这是我尝试使用的代码:

from collections import UserList
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.customaudience import CustomAudience
from facebook_business.api import FacebookAdsApi

test_id = '2385040704549815'

api = FacebookAdsApi.init(access_token=access_token)

session_id = '123456789'
session = {
            'session_id':session_id, 
            'batch_seq': 1, 
            'last_batch_flag':False, 
            }

# List of hashed email addresses (SHA256)
test_audience_list = ["8b84db83027ecd2764ac56dd6ed62aa761ea315e0268c64e34104a6536f"]

# I can add a list of users to a custom audience using this
CustomAudience(test_id).add_users(schema="EMAIL_SHA256", users=test_audience_list)

# I'm unable to replace all users with a new list
CustomAudience(test_id).create_users_replace(fields=None, params=None, batch=None)

我也尝试过包含 session 参数:

CustomAudience(test_id).create_users_replace(fields=None, params=None, batch=None, success=None, failure=None, session=session)

但随后我收到有关意外关键字参数“会话”的错误。

是否可以使用新列表替换自定义受众中的​​所有用户?最好的方法是什么?

4

0 回答 0