什么是EncodingAESKey? 一洽采用AES对称加密算法对消息体对行加密,EncodingAESKey则是加密所用的秘钥。消息接收方用此秘钥对收到的密文消息体进行解密。
消息加解密过程和微信公众平台的消息加解密方式一致。 示例代码(包括C++、php、Java、Python和C#版本)示例代码 注:一洽的签名信息在GET请求中,微信的示例代码签名在XML结构中,Encrypt节点的加解密方式是一样的。
Java要求jdk 1.6及1.6以上 异常java.security.InvalidKeyException:illegal Key Size的解决方案:在官方网站下载JCE无限制权限策略文件(请到官网下载对应的版本, 例如JDK7的下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html 下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt,如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件;如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件
网页代码中集成已有和对话相关业务数据时,可设置formData参数将业务自定义信息通过加密的方式通知到本地对话。 示例:
比如有formData的加密文本为:
xxxxxxxxxx
DYRi/vivtV0jpVOmPMulc8dkqByPv8nzoUplkVqHPsIrFptxqzgEL7toH5+i1l2YoiL3vYVhdw4C6mBISdK22PcO+61zfNbxyoRiSYwmn/nKi2kXel62Vu3SChVIvMMivroSNOLY8SeX2sCs+MS2H7KTFD7ZlQQsxgjUkAuQ4iEgQf6IGspcgDknTK25TswauOp80IBEREDcJO0qPRcmO87iDltwA0AHfezy0Jwrn++4mR0cNxTK5TEA0j/88XjaSt8rhReR2EL7+iYRn2ESwqZr/l6rwyn/9/NqOVdgI63Y/NSse29YIahgzLxfIinAU7W2kNlJE7fKyzkxZOf+WB4dLxqeJtKoE9vw0MU0rh/ai+kXFfNsTz1tKYQbel15Y27wH/YvqHx6uLqMQBYfdYjYsNnLfbe/nSxf0b2eRj8cf4Ut/6qCh2ctSWgcHw5SO8mqYdxQe3K+DtYJGl/OZZacHggh9pD/V69sESbwgmzrpQG+MQCmP6LpsolPRqfCpJKVWsek4m4hzhG5D/jrbRt2CwRRHii9yimAFIrDg+UFEhVz6xT5rxwD/nHm1I4ViQwj+PRFnguuEMM4/QIhNw==
示例:
xxxxxxxxxx
<script type="text/javascript">
var _echatServer = ['e.echatsoft.com'];
window._echat=window._echat||function(){(_echat.q=_echat.q||[]).push(arguments)};_echat.l=+new Date;
_echat('initParam', { companyId: 1});
_echat('initParam', { formData: 'DYRi/vivtV0jpVOmPMulc8dkqByPv8nzoUplkVqHPsIrFptxqzgEL7toH5+i1l2YoiL3vYVhdw4C6mBISdK22PcO+61zfNbxyoRiSYwmn/nKi2kXel62Vu3SChVIvMMivroSNOLY8SeX2sCs+MS2H7KTFD7ZlQQsxgjUkAuQ4iEgQf6IGspcgDknTK25TswauOp80IBEREDcJO0qPRcmO87iDltwA0AHfezy0Jwrn++4mR0cNxTK5TEA0j/88XjaSt8rhReR2EL7+iYRn2ESwqZr/l6rwyn/9/NqOVdgI63Y/NSse29YIahgzLxfIinAU7W2kNlJE7fKyzkxZOf+WB4dLxqeJtKoE9vw0MU0rh/ai+kXFfNsTz1tKYQbel15Y27wH/YvqHx6uLqMQBYfdYjYsNnLfbe/nSxf0b2eRj8cf4Ut/6qCh2ctSWgcHw5SO8mqYdxQe3K+DtYJGl/OZZacHggh9pD/V69sESbwgmzrpQG+MQCmP6LpsolPRqfCpJKVWsek4m4hzhG5D/jrbRt2CwRRHii9yimAFIrDg+UFEhVz6xT5rxwD/nHm1I4ViQwj+PRFnguuEMM4/QIhNw=='});
(function () {
var echat = document.createElement('script');
echat.type = 'text/javascript';
echat.async = true;
echat.id = 'echatmodulejs';
echat.setAttribute('charset','UTF-8');
echat.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'es.echatsoft.com/visitor/echat.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(echat, s);
})();
</script>
示例:
xxxxxxxxxx
https://es.echatsoft.com/visitor/pc/chat.html?companyId=1&formData=DYRi%2FvivtV0jpVOmPMulc8dkqByPv8nzoUplkVqHPsIrFptxqzgEL7toH5%2Bi1l2YoiL3vYVhdw4C6mBISdK22PcO%2B61zfNbxyoRiSYwmn%2FnKi2kXel62Vu3SChVIvMMivroSNOLY8SeX2sCs%2BMS2H7KTFD7ZlQQsxgjUkAuQ4iEgQf6IGspcgDknTK25TswauOp80IBEREDcJO0qPRcmO87iDltwA0AHfezy0Jwrn%2B%2B4mR0cNxTK5TEA0j%2F88XjaSt8rhReR2EL7%2BiYRn2ESwqZr%2Fl6rwyn%2F9%2FNqOVdgI63Y%2FNSse29YIahgzLxfIinAU7W2kNlJE7fKyzkxZOf%2BWB4dLxqeJtKoE9vw0MU0rh%2Fai%2BkXFfNsTz1tKYQbel15Y27wH%2FYvqHx6uLqMQBYfdYjYsNnLfbe%2FnSxf0b2eRj8cf4Ut%2F6qCh2ctSWgcHw5SO8mqYdxQe3K%2BDtYJGl%2FOZZacHggh9pD%2FV69sESbwgmzrpQG%2BMQCmP6LpsolPRqfCpJKVWsek4m4hzhG5D%2FjrbRt2CwRRHii9yimAFIrDg%2BUFEhVz6xT5rxwD%2FnHm1I4ViQwj%2BPRFnguuEMM4%2FQIhNw%3D%3D
示例:
xxxxxxxxxx
ECHAT.customMiniChat({'formData':'DYRi%2FvivtV0jpVOmPMulc8dkqByPv8nzoUplkVqHPsIrFptxqzgEL7toH5%2Bi1l2YoiL3vYVhdw4C6mBISdK22PcO%2B61zfNbxyoRiSYwmn%2FnKi2kXel62Vu3SChVIvMMivroSNOLY8SeX2sCs%2BMS2H7KTFD7ZlQQsxg'})
业务自定义信息接入时可携带的参数列表如下:
属性 | 类型 | 必填 | 描述 |
---|---|---|---|
chatSubject | int | 否 | 业务主题的id,该id是公司已存在的主题id;id>10 |
chatSubjectMemo | string | 否 | 业务主题评估的备注信息;最长不超过50 |
m1 - m10 | string | 否 | 业务自定义字段的value值;最长不超过50 |
密文业务自定义字段信息生成过程: 1.将需要传递给一洽的用户信息组装成xml格式
x<xml>
<chatSubject><![CDATA[1]]></chatSubject>
<chatSubjectMemo><![CDATA[备注]]></chatSubjectMemo>
<m1><![CDATA[1]]></m1>
<m2><![CDATA[2]]></m2>
<m3><![CDATA[3]]></m3>
<m4><![CDATA[4]]></m4>
<m5><![CDATA[5]]></m5>
<m6><![CDATA[6]]></m6>
<m7><![CDATA[7]]></m7>
<m8><![CDATA[8]]></m8>
<m9><![CDATA[9]]></m9>
<m10><![CDATA[10]]></m10>
</xml>
2.通过AES将明文内容进行加密 下面所有的加密示例所使用的的appid和encodingAesKey如下:
xappId:myAPPID
encodingAesKey:43weiyiqiaencodingAesKey1111111111111111111
加密后得到的密文如下:
xxxxxxxxxx
+SuunxStZ56xkQ2xTsnF9IP0qcfxG9+g84XjWBDDc+AZGOh+Cmw7nm0lHRjmEnGQBAcUjN0jSMo/gn4rk5VD22/aTPrlapUoXrhQXUToesDK2qoBJkI+Yt74gPmDB/HZgfPb3SFjv+PvZYDEXVEQCuXY+aZRwf3qY3UWHdWP9b8dvhkl9xnDVfFwKqOZhyUEoybNzg1UtJf88ELv/7ifrYFB8sC6950DaIKEmvKrF5PnzyGosnI1Wkvz5XvzD/XB9MdopC9uGvyyt7qIq/m9oz5PDRIOGgwRmSJ0mQNVrXpefEU4UI1ouW5k4iUhthwOpX3EG6UPwgfOwQVBeGy9WNJc8W9Doh1jod6SIhyN+pynFAeIGAdFSeK6IRMrSFggFU3tL9zfWt3fBUzAR8f7Um/yeGezLAUglRYkrZ5RfbIUvUzo1Wueb6zK/4KncaYNjoBFkO1tChm/b6wExd6GCH/wzGqANwUYzvQQNarrOHMEjSiARoWfGTJ86m3Yd8vrKgguPCmdwmupoQ0dKZwloAFKRFARXuPddfCWj4+OZpE=
注:通过对话地址方式传递给一洽的formData要进行urlEncode进行utf8编码后传参,避免特殊字符导致截断解密失败。