取得選件(Python)
最後更新: 2024年7月20日
建立對象:
- undefined
說明
get_offers()
用於執行決定並從Adobe Target擷取體驗。
方法
getOffers
target_client_instance.get_offers(options)
參數
options
dict具有下列結構:
名稱 | 類型 | 必要 | 預設值 | 說明 |
---|---|---|---|---|
請求 | DeliveryRequest | 是 | 無 | 符合Target Delivery API要求 |
target_cookie | str | no | 無 | Target Cookie |
target_location_hint | str | no | 無 | Target位置提示 |
consumer_id | str | no | 無 | 拼接多個呼叫時,應提供不同的消費者ID |
customer_ids | 清單[CustomerId] | no | 無 | VisitorId相容格式的客戶ID清單 |
session_id | str | no | 無 | 用於連結多個請求 |
callBack | 可呼叫 | no | 無 | 如果以非同步方式處理請求,則會在回應就緒時叫用回呼 |
err_callback | 可呼叫 | no | 無 | 如果以非同步方式處理請求,則會在引發例外狀況時叫用錯誤回呼 |
傳回值
如果同步呼叫(預設),則傳回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] | 回應Token的清單 |
meta | dict | 用於裝置上決策的其他決策中繼資料 |
用來將資料傳回瀏覽器的target_cookie
和target_location_hint_cookie
物件具有以下結構:
名稱 | 類型 | 說明 |
---|---|---|
名稱 | 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_views | 清單[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