抖音私信的订阅服务,我们需要去抖音开放平台-》管理中心-》webhooks,填入自己的外网地址,服务器必须支持https 服务,例如https://www.xx.com/xx, 后台代码如下:
@RequestMapping(value = "https://www.it610.com/dy/message/im", method = RequestMethod.POST)
@CrossOrigin(origins = "*", maxAge = 3600)
public String getDyImMessage( HttpServletRequest request ){
Map dataParams = FormatReqResDataParamsUtils.getRequestParams(request);
String event = (String) dataParams.get("event");
if(event.equals("verify_webhook")){
Map content = (Map) dataParams.get("content");
return JSON.toJSONString(content);
}
return JSON.toJSONString(new HashMap());
}
public static Map getRequestParams(HttpServletRequest request) {
BufferedReader bufferReader;
try {
bufferReader = new BufferedReader(request.getReader());
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = bufferReader.readLine()) != null) {
sb.append(line);
}
String decodeUrl = URLDecoder.decode(sb.toString(), "UTF-8");
Map addReptitleData =https://www.it610.com/article/new Gson().fromJson(decodeUrl, Map.class);
if (addReptitleData.containsKey("data")) {
String allDataParams = URLDecoder.decode((String) addReptitleData.get("data"), "UTF-8");
Map params = new Gson().fromJson(allDataParams, Map.class);
return params;
}
return addReptitleData;
}catch(Exception e) {
return new HashMap();
}
}
【java|抖音开放平台, 企业号私信订阅服务 java(公开的)】
推荐阅读
- 面试|秋招已至,抓紧备一波蚂蚁金服、字节跳动、阿里等大厂面试,冲刺金九银十!!
- java|Java开发四年遇瓶颈,决心跳槽入字节,四面后成功斩获45万offer!!
- java|(Java岗面试)耗时1月最新整理了20个技术栈的大厂面试题+解析+面经!
- java|盘它!分布式+框架+微服务+性能优化等,一篇拿下架构大全!
- windows|NSSM - 将任何exe应用封装成windows服务的神器
- Jdbi3|SpringBoot中Jdbi3使用多数据源详解
- MyBatis|SpringBoot & Mybatis-Plus实现多数据源的方法
- spring|Spring Boot项目下JPA自定义雪花算法ID生成器详解
- Java语言|logback通过EvaluatorFilter实现同时记录多个level级别的日志