获取选件(Python)
最近更新: 2025年5月5日
- 主题:
- APIs/SDKs
创建对象:
- 开发人员
描述
get_offers()
用于执行决策并从Adobe Target检索体验。
方法
getOffers
target_client_instance.get_offers(options)
参数
options
dict具有以下结构:
名称 | 类型 | 必需 | 默认 | 描述 |
---|---|---|---|---|
request | DeliveryRequest | 是 | 无 | 符合Target Delivery API请求 |
target_cookie | str | 否 | 无 | Target Cookie |
target_location_hint | str | 否 | 无 | Target位置提示 |
consumer_id | str | 否 | 无 | 在拼接多个调用时,应提供不同的消费者ID |
customer_ids | 列表[CustomerId] | 否 | 无 | 与VisitorId兼容的格式的客户ID列表 |
session_id | str | 否 | 无 | 用于链接多个请求 |
callback | 可调用 | 否 | 无 | 如果异步处理请求,则会在响应就绪时调用回调 |
err_callback | 可调用 | 否 | 无 | 如果异步处理请求,则在引发异常时会调用错误回调 |
返回值
如果同步调用,则返回TargetDeliveryResponse
(默认);如果通过回调调用,则返回AsyncResult
。 TargetDeliveryResponse
具有以下结构:
名称 | 类型 | 描述 |
---|---|---|
响应 | DeliveryResponse | 符合Target Delivery API响应 |
target_cookie | dict | Target Cookie |
target_location_hint_cookie | dict | Target位置提示Cookie |
analytics_details | 列表[AnalyticsResponse] | 在使用客户端Analytics的情况下,使用Analytics有效负载 |
trace | 列表[dict] | 所有请求mbox/视图的汇总跟踪数据 |
response_tokens | 列表[dict] | 响应令牌的列表 |
meta | dict | 用于设备上决策的其他决策元数据 |
用于将数据传递回浏览器的target_cookie
和target_location_hint_cookie
对象具有以下结构:
名称 | 类型 | 描述 |
---|---|---|
name | str | Cookie 名称 |
value | any | Cookie值,该值将转换为字符串 |
max_age | int | 为方便设置max_age option 相对于当前时间(以秒为单位)的过期时间 |
用于指示目标响应状态的meta
对象具有以下结构:
名称 | 类型 | 描述 |
---|---|---|
decisioning_method | str | 使用的决策方法:设备上或服务器端 |
remote_mboxes | 列表[str] | 当决策方法为on-device 时,会提供一个无法完全在设备上决策的mbox名称数组。 换句话说,需要Target Delivery API请求。 |
remote_view | 列表[str] | 当决策方法为设备上时,给出了无法完全决策为设备上视图名称的数组。 换句话说,需要Target Delivery API请求。 |
示例
Python
def client_ready_callback():
context = Context(channel=ChannelType.WEB)
mboxes = [MboxRequest(name="a1-serverside-ab", index=1)]
execute = ExecuteRequest(mboxes=mboxes)
delivery_request = DeliveryRequest(context=context, execute=execute)
get_offers_options = {
"request": delivery_request
}
target_delivery_response = target_client.get_offers(get_offers_options)
client_options = {
"client": "acmeclient",
"organization_id": "1234567890@AdobeOrg",
"events": {
"client_ready": client_ready_callback
}
}
target_client = TargetClient.create(client_options)
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3