postEvent(String sessionID, String eventName, NameValuePairImpl[] eventParameters)
|
sessionID—a string identifying the session id.
|
|
eventName—a string identifying the name of the event.
|
|
eventParameters—NameValuePairImpl objects identifying any parameters that need to be passed with the event. These values are stored in the session data.
|
|
|
There are several other reserved parameters used with postEvent and other methods and are discussed later in this section.
|
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());
Copyright IBM Corporation 2013. All Rights Reserved.
|