postEvent
postEvent 方法使您可以执行交互式渠道中定义的任何事件。
postEvent(String sessionID, String eventName, NameValuePairImpl[] eventParameters)
*
sessionID:用于标识会话标识的字符串。
*
eventName:用于标识事件名称的字符串。
*
*
eventParametersNameValuePairImpl 对象标识需要与事件一起传递的任何参数。这些值存储在会话数据中。
如果此事件触发重新划分细分市场,那么您必须确保交互式流程图需要的所有数据在会话数据中均可用。如果其中任何值尚未由先前操作填充(例如,从 startSessionsetAudience,或者装入概要文件表),那么您必须为每个缺失值包含一个 eventParameter。例如,如果您已配置了所有要装入到内存的概要文件表,那么必须为交互式流程图所需的临时数据包含一个 NameValuePair。
如果您在使用一个以上的受众级别,那么您很有可能针对每个受众级别具有不同组的 eventParameters。您应包含某些逻辑以确保您在为受众级别选择一组正确的参数。
*
您只能为每个事件传递一个处理代码。如果不为商品联系传递处理代码,那么 Interact 将为上一个商品建议列表中的每个商品记录一个商品联系。如果不为响应传递处理代码,那么 Interact 将返回错误。
*
还有其他一些保留参数用于 postEvent 和其他方法,本节中后面的部分将进行讨论。
针对重新划分细分市场或写入到联系或响应历史记录的任何请求都不会等待响应。
除非通过 UACIExecuteFlowchartByName 参数来指定,否则细分市场重新划分将为当前受众级别运行与此交互式渠道相关联的所有交互式流程图。getOffers 方法在运行之前将等待细分市场重新划分完成。因此,如果您在 getOffers 调用之前立即调用一个可触发细分市场重新划分的 postEvent 方法,那么可能会有延迟。
返回值
运行时服务器对应于 postEvent,后者包含填充了以下属性的 Response 对象:
*
*
*
*
示例
以下 postEvent 示例表明了为某个触发重新划分细分市场的事件发送新参数以及处理响应的方法。
sessionId 是相同字符串,用于标识启动此会话的 startSession 调用所使用的会话。
String eventName = "SearchExecution";

NameValuePair parmB1 = new NameValuePairImpl();
parmB1.setName("SearchString");
parmB1.setValueAsString("mortgage");
parmB1.setValueDataType(NameValuePair.DATA_TYPE_STRING);

NameValuePair parmB2 = new NameValuePairImpl();
parmB2.setName("TimeStamp");
parmB2.setValueAsDate(new Date());
parmB2.setValueDataType(NameValuePair.DATA_TYPE_DATETIME);

NameValuePair parmB3 = new NameValuePairImpl();
parmB3.setName("Browser");
parmB3.setValueAsString("IE6");
parmB3.setValueDataType(NameValuePair.DATA_TYPE_STRING);

NameValuePair parmB4 = new NameValuePairImpl();
parmB4.setName("FlashEnabled");
parmB4.setValueAsNumeric(1.0);
parmB4.setValueDataType(NameValuePair.DATA_TYPE_NUMERIC);

NameValuePair parmB5 = new NameValuePairImpl();
parmB5.setName("TxAcctValueChange");
parmB5.setValueAsNumeric(0.0);
parmB5.setValueDataType(NameValuePair.DATA_TYPE_NUMERIC);

NameValuePair parmB6 = new NameValuePairImpl();
parmB6.setName("PageTopic");
parmB6.setValueAsString("");
parmB6.setValueDataType(NameValuePair.DATA_TYPE_STRING);

NameValuePair[] postEventParameters = { parmB1,
parmB2,
parmB3,
parmB4,
parmB5,
parmB6
};

/** Make the call */
response = api.postEvent(sessionId, eventName, postEventParameters);

/** Process the response appropriately */
// check if response is successful or not
if(response.getStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("postEvent call processed with no warnings or errors");
}
else if(response.getStatusCode() == Response.STATUS_WARNING)
{
System.out.println("postEvent call processed with a warning");
}
else
{
System.out.println("postEvent call processed with an error");
}

// For any non-successes, there should be advisory messages explaining why
if(response.getStatusCode() != Response.STATUS_SUCCESS)
printDetailMessageOfWarningOrError("postEvent",
response.getAdvisoryMessages());