文档TargetTarget开发人员指南

获取选件(Python)

最近更新: 2025年5月5日
  • 主题:
  • APIs/SDKs

创建对象:

  • 开发人员

描述

get_offers()用于执行决策并从Adobe Target检索体验。

方法

getOffers

target_client_instance.get_offers(options)

参数

options dict具有以下结构:

名称类型必需默认描述
requestDeliveryRequest是无符合Target Delivery API请求
target_cookiestr否无Target Cookie
target_location_hintstr否无Target位置提示
consumer_idstr否无在拼接多个调用时,应提供不同的消费者ID
customer_ids列表[CustomerId]否无与VisitorId兼容的格式的客户ID列表
session_idstr否无用于链接多个请求
callback可调用否无如果异步处理请求,则会在响应就绪时调用回调
err_callback可调用否无如果异步处理请求,则在引发异常时会调用错误回调

返回值

如果同步调用,则返回TargetDeliveryResponse(默认);如果通过回调调用,则返回AsyncResult。 TargetDeliveryResponse具有以下结构:

名称类型描述
响应DeliveryResponse符合Target Delivery API响应
target_cookiedictTarget Cookie
target_location_hint_cookiedictTarget位置提示Cookie
analytics_details列表[AnalyticsResponse]在使用客户端Analytics的情况下,使用Analytics有效负载
trace列表[dict]所有请求mbox/视图的汇总跟踪数据
response_tokens列表[dict]​响应令牌的列表
metadict用于设备上决策的其他决策元数据

用于将数据传递回浏览器的target_cookie和target_location_hint_cookie对象具有以下结构:

名称类型描述
namestrCookie 名称
valueanyCookie值,该值将转换为字符串
max_ageint为方便设置max_age option相对于当前时间(以秒为单位)的过期时间

用于指示目标响应状态的meta对象具有以下结构:

名称类型描述
decisioning_methodstr使用的决策方法:设备上或服务器端
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