Parameters | Description |
signature | Encryption signature. It combines the timestamp, nonce and user input token. |
timestamp | Timestamp |
nonce | Random number |
echostr | Random string |
Parameters | Description |
sap-user | Communication user you assigned to the communication arrangement |
sap-password | Password of sap-user |
signature , bd24980c7a719cc1ca8b0f04298ed905ad899219
echostr , 4009760200478008056
timestamp , 1531814584
nonce , 51727410
<xml>
<ToUserName><![CDATA[gh_7c2518c75a2f]]></ToUserName>
<FromUserName><![CDATA[olvNV0b9PK1jnPcvl0ziNSwK2tws]]></FromUserName>
<CreateTime>1531390272</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[测试文本]]></Content>
<MsgId>6577271136077938084</MsgId>
</xml>
@RequestMapping(value = "/mkt/lineinbound/account1", method = RequestMethod.POST)
@ResponseBody
publicvoid doAction(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
String body = readAsChars(request);
String signature = request.getHeader("x-line-signature");
String respMsg = sync2Account1(body, signature);
out.write(respMsg);
out.close();
}
public String sync2Account1(String body)
{
String respMsg = "";
//Input SAP Marketing Digital Account Url
String mktUrl = "https://***-352.wdf.sap.corp:443/sap/cuan/ntwrk/*****************";
try
{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost(mktUrl);
post.addHeader("Content-Type", "text/xml;charset=utf-8");
post.addHeader("sap-user", "CC000000****");
post.addHeader("sap-password", "ftx****************zzvjN");
post.setEntity(new StringEntity(body));
CloseableHttpResponse resp = httpClient.execute(post);
HttpEntity entity = resp.getEntity();
String httpResult = EntityUtils.toString(entity);
respMsg = httpResult;
resp.close();
}
catch (Exception e)
{
e.printStackTrace();
}
return respMsg;
}
Parameters | Description |
sap-user | Communication user you assigned to the communication arrangement |
sap-password | Password of sap-user |
{
"events": [{
"type": "message",
"replyToken": "8be2688d4118464eaf437b62f1aa551b",
"source": {
"userId": "U0e6b7b252e4f9846e50cfe36aad439ee",
"type": "user"
},
"timestamp": 1531883571480,
"message": {
"type": "text",
"id": "8281113610204",
"text": "test"
}
}]
}
@RequestMapping(value = "/mkt/lineinbound/account1", method = RequestMethod.POST)
@ResponseBody
publicvoid doAction(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
String body = readAsChars(request);
String signature = request.getHeader("x-line-signature");
String respMsg = sync2Account1(body, signature);
out.write(respMsg);
out.close();
}
public String sync2Account1(String body)
{
String respMsg = "";
//Input SAP Marketing Digital Account Url
String mktUrl = "https://***-352.wdf.sap.corp:443/sap/cuan/ntwrk/941******************E4D";
try
{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost post = new HttpPost(mktUrl);
post.addHeader("Content-Type", "application/json");
post.addHeader("sap-user", "CC000000****");
post.addHeader("sap-password", "TJKgHtfAgkHv4********voAYHA");
//LINE header
post.addHeader("x-line-signature", signature);
post.setEntity(new StringEntity(body));
CloseableHttpResponse resp = httpClient.execute(post);
HttpEntity entity = resp.getEntity();
String httpResult = EntityUtils.toString(entity);
respMsg = httpResult;
resp.close();
}
catch (Exception e)
{
e.printStackTrace();
}
return respMsg;}
@RequestMapping(value = "/mkt/****inbound/account2",…) @ResponseBody public void doAction (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { … String respMsg = sync2Account2(body); … } |
public String sync2Account2(String body) { … //Input SAP Marketing Digital Account 2 Url String mktUrl = "*****************"; try { … //User & Password for Account 2 post.addHeader("sap-user", "*********"); post.addHeader("sap-password", "************************"); … } … } |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |