前言
- 集成配置
- 同步
- 单点
- 外联系统
- 智能办公
- 智能问答
- 智能体
本文主要讲解,第三方如何集成智能小e,集成常见问题和解决方案;
1、泛微OA产品集成
2、第三方如何集成
2.1、集成地址
集成地址,分为两个部分:
- 域名地址,如:https://cloud.qianliling.com/main
- pc端: https://cloud.qianliling.com/main/app-chat
- 移动端: https://cloud.qianliling.com/mobile-chat/#/index
- 移动端隐藏语音
https://cloud.qianliling.com/mobile-chat/#/index?disableVoice=true - pc端插件地址
https://cloud.qianliling.com/main/app-chat/chat-em - 采知连地址
https://cloud.qianliling.com/main/app-chat?czl=1
- 参数,
clientSource
、userToken
下面是集成登录的示例:
- pc端访问
https://cloud.qianliling.com/main/app-chat?clientSource=ecology&userToken=${userToken}
- pc端插件地址访问
https://cloud.qianliling.com/main/app-chat/chat-em?clientSource=ecology&userToken=${userToken}
- 手机端访问
https://cloud.qianliling.com/mobile-chat/#/index?clientSource=ecology&userToken=${userToken}
2.2、获取密钥
字段 | 说明 |
---|---|
appKey | 集成千里聆API调用信息,API秘钥中的SecretId ,参考下图 |
secretKey | 集成千里聆API调用信息,API秘钥中的SecretIdKey ,参考下图 |
2.3、如何生成签名sign
加密生成sign参数需要四个参数生成,分别是:appKey
、secretKey
、params
和timestamp
。
字段 | 说明 |
---|---|
appKey | 集成千里聆API调用信息,API秘钥中的SecretId |
secretKey | 集成千里聆API调用信息,API秘钥中的SecretIdKey |
params | 自选参数,json格式的对象,key-value都是字符串。 示例值: {“appKey”: “dsfs”} |
timestamp | 当前时间戳(毫秒数)。示例值:1627983230687 |
说明
关于sign
生成规则,生成方式:Md5(appKey + secretKey + params + timestamp).toUpperCase()
关于md5加密参数使用的是第三方jar包:commons-codec-1.13.jar,自己实现时,参考上述依赖包标准即可。
参数
params
说明
单点登录时,关于参数params
不能为空,其中必填
字段,如下
字段 | 说明 |
---|---|
appKey | 集成千里聆API调用信息,API秘钥中的SecretId ,参考上图 |
clientSource | String, 登录客户端类型值为:e9 , e10 , e-teams , e-office , qiyuesuo , 默认ecology |
ecUserId | 用户id,这里是ecology人员id |
ecUserName | 用户姓名 |
appSkip | 登录后直接跳转的页面地址 |
参考示例代码:
public class SingleParam {
// 千里聆给客户分配的AK--例如:mD0XRABC
private String appKey;
// 千里聆给客户分配的SK--例如:sdfssafdsafdasfdasf32423423
private String secretKey;
// 登录客户端类型 登录客户端类型值为:`e9`, `e10` , `e-teams` , `e-office` , `qiyuesuo` , `ecology`默认
private String clientSource;
// 第三方人员唯一标识
private String ecUserId;
// 用户姓名
private String ecUserName;
// 单点登录后访问的页面地址
private String appSkip;
/**
* 构造 加密参数 用于点单登录
*/
public Map<String, String> getParams(){
Map<String, String> params = new HashMap<>();
params.put("appKey", URLEncoder.encode(appKey, "utf-8"));
params.put("clientSource", URLEncoder.encode(clientSource, "utf-8"));
params.put("ecUserId", URLEncoder.encode(ecUserId, "utf-8"));
params.put("ecUserName", URLEncoder.encode(ecUserName, "utf-8"));
params.put("appSkip", URLEncoder.encode(appSkip, "utf-8"));
return params;
}
}
2.4、如何生成userToken
- 接口地址(URI):https://cloud.qianliling.com/rpa/auth/app/user/generateUserToken
- 接口请求类型:POST
- 接口内容类型:Content-Type: application/json
接口参数
参数示例:
{
"appKey": "fafa43234",
"sign": "fsd68fsaf823fsdfafas",
"timestamp": "16669000200",
"params": {
"appKey": "wwrwer",
"clientSource": "ecology",
"ecUserId": "1234",
"ecUserName": "zhangsan",
"appSkip": ""
}
}
参数说明
参数名称 | 类型 | 描述 |
---|---|---|
appKey | String | 集成千里聆API调用信息,API秘钥中的SecretId ,参考2.2、获取密钥 |
sign | String | 签名,按照appKey、secretKey、params、timestamp的顺序进行拼接生成的16进制大写的MD5字符串,参考2.3、如何生成签名sign |
timestamp | String | 当前时间戳(毫秒数)。示例值:1627983230687 |
params | Object | 自选参数,json格式的对象, 参考:SingleParam |
接口返回结果
{
"code": "0000",
"msg": "请求成功",
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwZXJtaXNzaWc..."
}
返回字段 | 类型 | 描述 |
---|---|---|
code | String | 0000 -表示成功,否则失败 |
msg | String | 失败信息 |
data | String | userToken的值 |
参考示例代码:
说明
关于sign
生成规则,需要使用params ,这里使用HashMap实现,无法保证顺序,所有json序列化时,为了保证一致,请使用gson
public class Demo {
private String url = "https://cloud.qianliling.com/rpa/auth/app/user/generateUserToken";
public String getToken() {
String appKey = "";
String secretKey = "";
SingleParam singleParam = new SingleParam();
// 注意这里使用HashMap,无法保证顺序,所有json序列化时,为了保证一致,请使用gson
Map<String, String> params = singleParam.getParams();
long timestamp = System.currentTimeMillis();
String str = appKey + secretKey + params + timestamp;
String sign = DigestUtils.md5Hex(str.getBytes()).toUpperCase();
Map<String, Object> body = new HashMap<>();
body.put("appKey", appKey);
body.put("params", params);
body.put("timestamp", timestamp);
body.put("sign", sign);
String userToken = null;
// 执行 httpClient 调用, 请参考:生成userToken 接口文档
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse httpResponse = null;
try {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
// 创建 HttpPost 参数
Gson gson = new Gson();
StringEntity stringEntity = new StringEntity(gson.toJson(body), "UTF-8");
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
String content = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
Map<String, String> resMap = gson.fromJson(content, new TypeToken<Map<String, String>>() {
}.getType());
// 获取 userToken 并返回
userToken = resMap.get("data");
} catch (Exception e) {
} finally {
try {
if (httpResponse != null) {
httpResponse.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return userToken;
}
}