JAVA集成腾讯云即时通讯IM服务端

一. 腾讯IM快速入门
1. 注册腾讯云账号,找到即时通信IM控制台
腾讯IM控制台:登录 - 腾讯云

2. 创建即时通信应用

watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6JCM5pif5Lq6,size_20,color_FFFFFF,t_70,g_se,x_16
3. 进到应用里面可以看到这个应用的SDKAppID和key(密钥)

 watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6JCM5pif5Lq6,size_20,color_FFFFFF,t_70,g_se,x_16


4. 可以参考官方提供的“服务端API接口文档”和“接口调试工具”
API接口文档:https://cloud.tencent.com/document/product/269
接口在线调试工具:https://tcc.tencentcs.com/im-api-tool/index.html
二. 基于Java对一些方法的简单封装
注:封装的方法覆盖得肯定不全面,可以根据自身需求在此基础上补充

1. 配置文件
#腾讯im相关配置

silence.tencent.cloud.im.sdkAppId=应用SDKAppId
silence.tencent.cloud.im.key=应用Key


2. 腾讯im相关API接口常量类TencentCloudImApiConstant.java

public class TencentCloudImApiConstant {/*** 账号管理*/public static class AccountManage {/**导入单个帐号*/public static final String ACCOUNT_IMPORT = "v4/im_open_login_svc/account_import";/**导入多个帐号*/public static final String MULTI_ACCOUNT_IMPORT = "v4/im_open_login_svc/account_import";/**删除帐号*/public static final String ACCOUNT_DELETE = "v4/im_open_login_svc/account_delete";/**查询帐号*/public static final String ACCOUNT_CHECK = "v4/im_open_login_svc/account_check";/**失效帐号登录状态*/public static final String ACCOUNT_KICK = "v4/im_open_login_svc/kick";/**查询账号在线状态*/public static final String ACCOUNT_QUERY_STATE = "v4/openim/querystate";}/*** 单聊消息*/public static class SingleChatManage {/**单发单聊消息*/public static final String SEND_MSG = "v4/openim/sendmsg";/**批量发单聊消息*/public static final String BATCH_SEND_MSG = "v4/openim/batchsendmsg";/**导入单聊消息*/public static final String IMPORT_MSG = "v4/openim/importmsg";/**查询单聊消息*/public static final String ADMIN_GET_ROAM_MSG = "v4/openim/admin_getroammsg";/**撤回单聊消息*/public static final String ADMIN_MSG_WITH_DRAW = "v4/openim/admin_msgwithdraw";/**设置单聊消息已读*/public static final String ADMIN_SET_MSG_READ = "v4/openim/admin_set_msg_read";}/*** 全员推送*/public static class AllPushManage {/**全员推送*/public static final String IM_PUSH = "v4/all_member_push/im_push";/**设置应用属性名称*/public static final String IM_SET_ATTR_NAME = "v4/all_member_push/im_set_attr_name";/**获取应用属性名称*/public static final String IM_GET_ATTR_NAME = "v4/all_member_push/im_get_attr_name";/**获取用户属性*/public static final String IM_GET_ATTR = "v4/all_member_push/im_get_attr";/**设置用户属性*/public static final String IM_SET_ATTR = "v4/all_member_push/im_set_attr";/**删除用户属性*/public static final String IM_REMOVE_ATTR = "v4/all_member_push/im_remove_attr";/**获取用户标签*/public static final String IM_GET_TAG = "v4/all_member_push/im_get_tag";/**添加用户标签*/public static final String IM_ADD_TAG = "v4/all_member_push/im_add_tag";/**删除用户标签*/public static final String IM_REMOVE_TAG = "v4/all_member_push/im_remove_tag";/**删除用户所有标签*/public static final String IM_REMOVE_ALL_TAGS = "v4/all_member_push/im_remove_all_tags";}/*** 资料管理*/public static class PortraitManage {/**设置资料*/public static final String PORTRAIT_SET = "v4/profile/portrait_set";/**拉取资料*/public static final String PORTRAIT_GET = "v4/profile/portrait_get";}/*** 关系链管理*/public static class RelationManage {/**添加好友*/public static final String FRIEND_ADD = "v4/sns/friend_add";/**导入好友*/public static final String FRIEND_IMPORT = "v4/sns/friend_import";/**更新好友*/public static final String FRIEND_UPDATE = "v4/sns/friend_update";/**删除好友*/public static final String FRIEND_DELETE = "v4/sns/friend_delete";/**删除所有好友*/public static final String FRIEND_DELETE_ALL = "v4/sns/friend_delete_all";/**校验好友*/public static final String FRIEND_CHECK = "v4/sns/friend_check";/**拉取好友*/public static final String FRIEND_GET = "v4/sns/friend_get";/**拉取指定好友*/public static final String FRIEND_GET_LIST = "v4/sns/friend_get_list";/**添加黑名单*/public static final String BLACK_LIST_ADD = "v4/sns/black_list_add";/**删除黑名单*/public static final String BLACK_LIST_DELETE = "v4/sns/black_list_delete";/**拉取黑名单*/public static final String BLACK_LIST_GET = "v4/sns/black_list_get";/**校验黑名单*/public static final String BLACK_LIST_CHECK = "v4/sns/black_list_check";/**添加分组*/public static final String GROUP_ADD = "v4/sns/group_add";/**删除分组*/public static final String GROUP_DELETE = "v4/sns/group_delete";/**拉取分组*/public static final String GROUP_GET = "v4/sns/group_get";}/*** 群组管理*/public static class GroupManage {/**创建群组*/public static final String CREATE_GROUP = "v4/group_open_http_svc/create_group";/**获取群详细资料*/public static final String GET_GROUP_INFO = "v4/group_open_http_svc/get_group_info";/**获取群成员详细资料*/public static final String GET_GROUP_MEMBER_INFO = "v4/group_open_http_svc/get_group_member_info";/**修改群基础资料*/public static final String MODIFY_GROUP_BASE_INFO = "v4/group_open_http_svc/modify_group_base_info";/**增加群成员*/public static final String ADD_GROUP_MEMBER = "v4/group_open_http_svc/add_group_member";/**删除群成员*/public static final String DELETE_GROUP_MEMBER = "v4/group_open_http_svc/delete_group_member";/**修改群成员资料*/public static final String MODIFY_GROUP_MEMBER_INFO = "v4/group_open_http_svc/modify_group_member_info";/**解散群组*/public static final String DESTROY_GROUP = "v4/group_open_http_svc/destroy_group";/**获取用户所加入的群组*/public static final String GET_JOINED_GROUP_LIST = "v4/group_open_http_svc/get_joined_group_list";/**查询用户在群组中的身份*/public static final String GET_ROLE_IN_GROUP = "v4/group_open_http_svc/get_role_in_group";/**批量禁言和取消禁言*/public static final String FORBID_SEND_MSG = "v4/group_open_http_svc/forbid_send_msg";/**获取被禁言群成员列表*/public static final String GET_GROUP_SHUT_UIN = "v4/group_open_http_svc/get_group_shutted_uin";/**在群组中发送普通消息*/public static final String SEND_GROUP_MSG = "v4/group_open_http_svc/send_group_msg";/**在群组中发送系统通知*/public static final String SEND_GROUP_SYSTEM_NOTIFICATION = "v4/group_open_http_svc/send_group_system_notification";/**撤回群消息*/public static final String GROUP_MSG_RECALL = "v4/group_open_http_svc/group_msg_recall";/**转让群主*/public static final String CHANGE_GROUP_OWNER = "v4/group_open_http_svc/change_group_owner";/**导入群基础资料*/public static final String IMPORT_GROUP = "v4/group_open_http_svc/import_group";/**导入群消息*/public static final String IMPORT_GROUP_MSG = "v4/group_open_http_svc/import_group_msg";/**导入群成员*/public static final String IMPORT_GROUP_MEMBER = "v4/group_open_http_svc/import_group_member";/**设置成员未读消息计数*/public static final String SET_UNREAD_MSG_NUM = "v4/group_open_http_svc/set_unread_msg_num";/**删除指定用户发送的消息*/public static final String DELETE_GROUP_MSG_BY_SENDER = "v4/group_open_http_svc/delete_group_msg_by_sender";/**拉取群历史消息*/public static final String GROUP_MSG_GET_SIMPLE = "v4/group_open_http_svc/group_msg_get_simple";/**获取直播群在线人数*/public static final String GET_ONLINE_MEMBER_NUM = "v4/group_open_http_svc/get_online_member_num";}/*** 全局禁言管理*/public static class AllSinentManage {/**设置全局禁言*/public static final String SET_NO_SPEAKING = "v4/openconfigsvr/setnospeaking";/**查询全局禁言*/public static final String GET_NO_SPEAKING = "v4/openconfigsvr/getnospeaking";}/*** 运营管理*/public static class OperationManage {/**拉取运营数据*/public static final String GET_APP_INFO = "v4/openconfigsvr/getappinfo";/**下载消息记录*/public static final String GET_HISTORY = "v4/open_msg_svc/get_history";/**获取服务器 IP 地址*/public static final String GET_IP_LIST = "v4/ConfigSvc/GetIPList";}
}


3. 腾讯im相关常量类TencentCloudImConstant.java

public class TencentCloudImConstant {/*** IM请求处理结果*/public final static String ACTION_STATUS_OK = "OK";public final static String ACTION_STATUS_FAIL = "FAIL";/*** IM发消息是否同步到发送方(1-同步,2-不同步)*/public final static Integer SYNC_OTHER_MACHINE_YES = 1;public final static Integer SYNC_OTHER_MACHINE_NO = 2;/*** IM消息对象类型:* TIMTextElem    文本消息。* TIMLocationElem    地理位置消息。* TIMFaceElem    表情消息。* TIMCustomElem    自定义消息,当接收方为 iOS 系统且应用处在后台时,此消息类型可携带除文本以外的字段到 APNs。一条组合消息中只能包含一个 TIMCustomElem 自定义消息元素。* TIMSoundElem    语音消息。* TIMImageElem    图像消息。* TIMFileElem    文件消息。* TIMVideoFileElem    视频消息。*/public final static String TIM_TEXT_ELEM = "TIMTextElem";public final static String TIM_LOCATION_ELEM = "TIMLocationElem";public final static String TIM_FACE_ELEM = "TIMFaceElem";public final static String TIM_CUSTOM_ELEM = "TIMCustomElem";public final static String TIM_SOUND_ELEM = "TIMSoundElem";public final static String TIM_IMAGE_ELEM = "TIMImageElem";public final static String TIM_FILE_ELEM = "TIMFileElem";public final static String TIM_VIDEOFILE_ELEM = "TIMVideoFileElem";/*** 微信响应消息类型* WX_MSG_TYPE_EVENT:事件类型,事件类型对应"user_enter_tempsession"表示建立会话* WX_MSG_TYPE_TEXT:文本类型* WX_MSG_TYPE_TEXT:图片类型* WX_MSG_TYPE_TEXT:小程序卡片*/public final static String WX_MSG_TYPE_EVENT = "event";public final static String WX_MSG_TYPE_TEXT = "text";public final static String WX_MSG_TYPE_IMAGE = "image";public final static String WX_MSG_TYPE_APPLET_CARD = "miniprogrampage";
}


4. 发送http请求工具类HttpUtil.java

import com.alibaba.fastjson.JSONObject;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;public class HttpUtil {private static final CloseableHttpClient httpclient = HttpClients.createDefault();/*** 发送HttpGet请求* @param url* @return*/public static String sendGet(String url) {HttpGet httpget = new HttpGet(url);CloseableHttpResponse response = null;try {response = httpclient.execute(httpget);} catch (IOException e1) {e1.printStackTrace();}String result = null;try {HttpEntity entity = response.getEntity();if (entity != null) {result = EntityUtils.toString(entity);}} catch (Exception e) {e.printStackTrace();} finally {try {response.close();} catch (IOException e) {e.printStackTrace();}}return result;}/*** 发送HttpPost请求,参数为map* @param url* @param map* @return*/public static String sendPost(String url, Map<String, String> map) {List<NameValuePair> formparams = new ArrayList<NameValuePair>();for (Map.Entry<String, String> entry : map.entrySet()) {formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));}UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);HttpPost httppost = new HttpPost(url);httppost.setEntity(entity);CloseableHttpResponse response = null;try {response = httpclient.execute(httppost);} catch (IOException e) {e.printStackTrace();}HttpEntity entity1 = response.getEntity();String result = null;try {result = EntityUtils.toString(entity1);} catch (Exception e) {e.printStackTrace();}return result;}/*** 发送不带参数的HttpPost请求* @param url* @return*/public static String sendPost(String url) {HttpPost httppost = new HttpPost(url);CloseableHttpResponse response = null;try {response = httpclient.execute(httppost);} catch (IOException e) {e.printStackTrace();}HttpEntity entity = response.getEntity();String result = null;try {result = EntityUtils.toString(entity);} catch (Exception e) {e.printStackTrace();}return result;}public static String doPost2(String url, JSONObject param) {HttpPost httpPost = null;String result = null;try {HttpClient client = new DefaultHttpClient();httpPost = new HttpPost(url);if (param != null) {StringEntity se = new StringEntity(param.toString(), "utf-8");httpPost.setEntity(se); // post方法中,加入json数据httpPost.setHeader("Content-Type", "application/json");httpPost.setHeader("Authorization", param.getString("authorization"));}HttpResponse response = client.execute(httpPost);if (response != null) {HttpEntity resEntity = response.getEntity();if (resEntity != null) {result = EntityUtils.toString(resEntity, "utf-8");}}} catch (Exception ex) {ex.printStackTrace();}return result;}
}


5. 腾讯im常用方法工具类TencentCloudImUtil.java

import com.alibaba.fastjson.JSONObject;
import com.example.tencentcloudim.constant.TencentCloudImApiConstant;
import com.example.tencentcloudim.constant.TencentCloudImConstant;
import com.tencentyun.TLSSigAPIv2;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;@Slf4j
@Component
public class TencentCloudImUtil {private static final String HTTPS_URL_PREFIX = "https://console.tim.qq.com/";private static final String APP_MANAGER = "administrator";private static final String REDIS_IM_USER_SIG = "silence:im_user_sig:";@Value("${silence.tencent.cloud.im.sdkAppId}")private long sdkAppId;@Value("${silence.tencent.cloud.im.key}")private String key;@Autowiredprivate RedisServiceUtil redisServiceUtil;/*** 获取腾讯云用户签名*/public String getTxCloudUserSig() {String userSig = redisServiceUtil.get(REDIS_IM_USER_SIG + APP_MANAGER);if (StringUtils.isEmpty(userSig)) {TLSSigAPIv2 tlsSigApi = new TLSSigAPIv2(sdkAppId, key);userSig = tlsSigApi.genUserSig(APP_MANAGER, 86400);redisServiceUtil.set(REDIS_IM_USER_SIG + APP_MANAGER, userSig, 86400L);}return userSig;}/*** 获取腾讯im请求路径*/private String getHttpsUrl(String imServiceApi, Integer random) {return String.format("%s%s?sdkappid=%s&identifier=%s&usersig=%s&random=%s&contenttype=json",HTTPS_URL_PREFIX, imServiceApi, sdkAppId, APP_MANAGER, this.getTxCloudUserSig(), random);}/*** 导入单个账号* @param userId 用户id*/public void accountImport(String userId) {accountImport(userId, null);}public void accountImport(String userId, String userName) {accountImport(userId, userName, null);}public void accountImport(String userId, String userName, String faceUrl) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.AccountManage.ACCOUNT_IMPORT, random);JSONObject jsonObject = new JSONObject();jsonObject.put("Identifier", userId);if (StringUtils.isNotEmpty(userName)) {jsonObject.put("Nick", userName);}if (StringUtils.isNotEmpty(faceUrl)) {jsonObject.put("FaceUrl", faceUrl);}log.info("腾讯云im导入单个账号,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im导入单个账号,返回结果:{}", result);}/*** 导入多个账号* @param userIds 用户id集合*/public void multiAccountImport(List<String> userIds) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.AccountManage.MULTI_ACCOUNT_IMPORT, random);JSONObject jsonObject = new JSONObject();jsonObject.put("Accounts", userIds);log.info("腾讯云im导入多个账号,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im导入单个账户,返回结果:{}", result);}/*** 删除账号* @param userIds 用户id集合*/public void accountDelete(List<String> userIds) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.AccountManage.ACCOUNT_DELETE, random);JSONObject jsonObject = new JSONObject();jsonObject.put("DeleteItem", getUserIdJsonList(userIds));log.info("腾讯云im删除账号,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im删除账户,返回结果:{}", result);}/*** 查询账号是否已经导入im* @param userIds 用户id集合*/public String accountCheck(List<String> userIds) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.AccountManage.ACCOUNT_CHECK, random);JSONObject jsonObject = new JSONObject();jsonObject.put("CheckItem", getUserIdJsonList(userIds));log.info("腾讯云im查询账号,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im查询账号,返回结果:{}", result);return result;}private List<JSONObject> getUserIdJsonList(List<String> userIds) {return userIds.stream().map(v -> {JSONObject userIdJson = new JSONObject();userIdJson.put("UserID", v);return userIdJson;}).collect(Collectors.toList());}/*** 单发单聊消息* @param syncOtherMachine 是否同步消息到发送方(1-同步,2-不同步)* @param fromUserId 发送方用户id* @param toUserId 接收方用户id* @param msgType 消息对象类型* @param msgContent 消息内容*/public String sendMsg(Integer syncOtherMachine, String fromUserId, String toUserId, String msgType, String msgContent) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.SingleChatManage.SEND_MSG, random);JSONObject jsonObject = new JSONObject();jsonObject.put("SyncOtherMachine", syncOtherMachine);if (StringUtils.isNotEmpty(fromUserId)) {// 发送方不为空表示指定发送用户,为空表示为管理员发送消息jsonObject.put("From_Account", fromUserId);}jsonObject.put("To_Account", toUserId);jsonObject.put("MsgRandom", random);List<JSONObject> msgBody = getMsgBody(msgType, msgContent);jsonObject.put("MsgBody", msgBody);log.info("腾讯云im单发单聊消息,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im单发单聊消息,返回结果:{}", result);return result;}/*** 批量发单聊消息* @param syncOtherMachine 是否同步消息到发送方(1-同步,2-不同步)* @param fromUserId 发送方用户id* @param toUserIds 接收方用户id集合* @param msgType 消息对象类型* @param msgContent 消息内容*/public String batchSendMsg(Integer syncOtherMachine, String fromUserId, List<String> toUserIds, String msgType, String msgContent) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.SingleChatManage.BATCH_SEND_MSG, random);JSONObject jsonObject = new JSONObject();jsonObject.put("SyncOtherMachine", syncOtherMachine);if (StringUtils.isNotEmpty(fromUserId)) {// 发送方不为空表示指定发送用户,为空表示为管理员发送消息jsonObject.put("From_Account", fromUserId);}jsonObject.put("To_Account", toUserIds);jsonObject.put("MsgRandom", random);List<JSONObject> msgBody = getMsgBody(msgType, msgContent);jsonObject.put("MsgBody", msgBody);log.info("腾讯云im批量发单聊消息,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im批量发单聊消息,返回结果:{}", result);return result;}/*** 拼接发送消息内容* @param msgType 消息类型* @param msgContent 发送消息内容* @return 消息内容*/private List<JSONObject> getMsgBody(String msgType, String msgContent) {List<JSONObject> msgBody = new ArrayList<>();if (msgType.equals(TencentCloudImConstant.TIM_TEXT_ELEM)) {// 文本类型JSONObject msgBodyJson = new JSONObject();msgBodyJson.put("MsgType", msgType);JSONObject msgContentObj = new JSONObject();msgContentObj.put("Text", msgContent);msgBodyJson.put("MsgContent", msgContentObj);msgBody.add(msgBodyJson);}return msgBody;}/*** 查询单聊消息* @param fromUserId 发送方用户id* @param toUserId 接收方用户id* @param maxCnt 查询条数* @param startTime 起始时间(单位:秒)* @param endTime 结束时间(单位:秒)* @param lastMsgKey 最后一条消息的 MsgKey* @return 单聊消息列表*/public String adminGetRoamMsg(String fromUserId, String toUserId, Integer maxCnt, Long startTime, Long endTime, String lastMsgKey) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.SingleChatManage.ADMIN_GET_ROAM_MSG, random);JSONObject jsonObject = new JSONObject();jsonObject.put("From_Account", fromUserId);jsonObject.put("To_Account", toUserId);jsonObject.put("MaxCnt", maxCnt);jsonObject.put("MinTime", startTime);jsonObject.put("MaxTime", endTime);if (StringUtils.isNotEmpty(lastMsgKey)){jsonObject.put("LastMsgKey", lastMsgKey);}log.info("腾讯云im查询单聊消息,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im查询单聊消息,返回结果:{}", result);return result;}/*** 撤回单聊消息* @param fromUserId 发送方用户id* @param toUserId 接收方用户id* @param msgKey MsgKey*/public void adminMsgWithDraw(String fromUserId, String toUserId, String msgKey) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.SingleChatManage.ADMIN_MSG_WITH_DRAW, random);JSONObject jsonObject = new JSONObject();jsonObject.put("From_Account", fromUserId);jsonObject.put("To_Account", toUserId);jsonObject.put("MsgKey", msgKey);log.info("腾讯云im撤回单聊消息,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im撤回单聊消息,返回结果:{}", result);}/*** 设置单聊消息已读* @param reportUserId 读取消息的用户* @param peerUserId 发送消息的用户*/public void adminSetMsgRead(String reportUserId, String peerUserId) {Integer random = RandomUtils.nextInt(0, 999999999);String httpsUrl = getHttpsUrl(TencentCloudImApiConstant.SingleChatManage.ADMIN_SET_MSG_READ, random);JSONObject jsonObject = new JSONObject();jsonObject.put("Report_Account", reportUserId);jsonObject.put("Peer_Account", peerUserId);log.info("腾讯云im设置单聊消息已读,请求参数:{}", jsonObject.toString());String result = HttpUtil.doPost2(httpsUrl, jsonObject);log.info("腾讯云im设置单聊消息已读,返回结果:{}", result);}
}

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/47784.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

100套基于Java开发的毕业设计项目,完成项目源码可共分为五季,每季大约20套项目,希望大家多多支持持续关注哦!

很多大三大四的学生&#xff0c;苦于没有参考的毕设资料&#xff0c;或者下载的资料零零散散、代码有问题、数据有问题等等&#xff0c;造成毕设出现问题影响大学毕业。 现在&#xff0c;我们提供了经过审核的100个项目源码和对应的辅导视频&#xff0c;让大家在短时间内可以完…

chatgpt赋能python:Python选择器的SEO优化

Python选择器的SEO优化 作为一名有10年Python编程经验的工程师&#xff0c;我深知Python在Web开发和SEO优化方面的重要性。在这篇文章中&#xff0c;我将会介绍Python选择器的SEO优化并阐述如何使用它。 什么是Python选择器&#xff1f; Python选择器是一种解析HTML、CSS、X…

当我们聊飞书时,我们应该聊什么?

飞书&#xff0c;2020年的明星产品。沉寂了许久的产品界&#xff0c;终于迎来了话题明星。 我们已经聊腻了抖音快手短视频&#xff0c;看烦了直播电商小商店。现在我们终于转移了视线&#xff0c;转移到了飞书身上。没错&#xff0c;这次还是字节跳动。 那么&#xff0c;当我们…

吴恩达ChatGPT《LangChain Chat with Your Data》笔记

文章目录 1. Introduction2. Document Loading2.1 Retrieval Augmented Generation&#xff08;RAG&#xff09;2.2 Load PDFs2.3 Load YouTube2.4 Load URLs2.5 Load Notion 3. Document Splitting3.1 Splitter Flow3.2 Character Splitter3.3 Token Splitter3.4 Markdown Spl…

协同办公笔记软件综合评测:飞书、语雀、Notion、FlowUs、Wolai

飞书文档 介绍 飞书文档汇集了文档、表格、思维笔记等在线创作工具&#xff0c;同时为文件提供安全、强大的云端存储和内容管理能力&#xff0c;文档所有者可以根据需要灵活设置浏览、编辑、评论、分享等权限&#xff0c;让协作有序又高效。 核心特色 文稿类型&#xff1a;包括…

差评近一半,用 Python 分析胡歌的《猎场》到底值不值得看?

作者 | 布道 11 月 6 日&#xff0c;湖南卫视已经开播被称作年度压轴的大戏“猎场”&#xff0c;迅速占领各大榜单&#xff0c;成为一部高热度的电视剧。但是在豆瓣上却形成了两极分化。截止 11 月 8 日&#xff0c;该剧在豆瓣上的评分为 5.7 分。相比较胡歌之前《琅琊榜》的 9…

你评论,我赠书~【哈士奇赠书 - 13期】-〖Python程序设计-编程基础、Web开发及数据分析〗参与评论,即可有机获得

大家好&#xff0c;我是 哈士奇 &#xff0c;一位工作了十年的"技术混子"&#xff0c; 致力于为开发者赋能的UP主, 目前正在运营着 TFS_CLUB社区。 &#x1f4ac; 人生格言&#xff1a;优于别人,并不高贵,真正的高贵应该是优于过去的自己。&#x1f4ac; &#x1f4…

【Thunder送书 | 第三期 】「Python系列丛书」

文章目录 前言《Python高效编程——基于Rust语言》《Python从入门到精通》《Python Web深度学习》《Python分布式机器学习》文末福利 | 赠书活动 前言 Thunder送书第三期开始啦&#xff01;前面两期都是以【文末送书】的形式开展&#xff0c;本期将赠送Python系列丛书&#xff…

chatgpt赋能python:Python怎么隐藏密码:常用的方法和技巧

Python怎么隐藏密码&#xff1a;常用的方法和技巧 互联网时代&#xff0c;用户需要经常输入账号密码来进行在线交互。但是&#xff0c;账户密码的安全性问题也随之而来。为了防止私人信息被泄露&#xff0c;很多应用程序都需要对用户密码进行加密和隐藏。本文将介绍Python中常…

chatgpt赋能python:Python安装和打开教程

Python安装和打开教程 Python作为一种高效、灵活、易学易用的编程语言&#xff0c;越来越受到广大程序员的青睐&#xff0c;越来越多的人想要学习Python。在学习Python之前&#xff0c;首先要进行Python的安装和打开。那么&#xff0c;本篇文章将为您介绍如何安装和打开Python…

10分钟建立一个自媒体秘书——国产企业级大模型文心千帆初体验

目录 一、文心千帆简介二、模型搭建与调优2.1、数据准备——为秘书准备资料2.2、模型调优——为秘书安排培训课2.3、模型发布——让秘书开始上班 三、大模型助力产业智能化变革3.1、AI航海的启航引擎——大模型3.2、文心千帆体验心得 当一个轻轻松松的甩手掌柜&#xff0c;让AI…

微信登录的接口

目录 第一步&#xff1a;生成微信扫描二维码(网页内嵌的二维码)接口第二步&#xff1a;处理微信回调 &#xff0c;获取扫描人信息 微信开放平台&#xff1a; https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Development_Guide.html 第一步&#xf…

IBOX NFT 数字藏品价格 监控 工具 科技

IBOX NFT 数字藏品价格监控工具 科技 -7月25号 由于原来的pc版本的科技使用的web端口&#xff0c;迫于ibox关闭的web端下单接口 所有不得已又开发了一个android的科技自用 锁单、监控、公告自动锁单、抢购、查询仓库交易信息 ibox 数字藏品最近比较火&#xff0c;所以开发…

通达信插件获取并存储通达信商品指数的实时数据

一、引子 通达信商品指数一共有23个&#xff0c;如下图所示&#xff1a; 如果想获取历史数据&#xff0c;只需要通过通达信的数据下载和导出功能即可&#xff0c;现在我们需要获取这23个指数的实时数据&#xff0c;通过导出功能就没有办法了。 在最初的阶段&#xff0c;考虑的…

免费获得筹码分布接口交易数据,Tushare的使用方法

在做量化交易时需要活动历史数据&#xff0c;Tushare是一个免费提供各类金融数据 , 助力智能投资与创新型投资的平台。在这个平台上可以免费获得股票、期货和外汇的各种数据。下面就给大家介绍一下Tushare的注册和使用方法。 使用流程是&#xff1a;1、用户注册 - 2、用户使用…

哪个软件能实盘测试策略,Quicklib提供期货CTA策略实盘模拟监控的好工具(原创)...

大家都知道开发期货程序化交易&#xff0c;是一个非常繁杂的工作&#xff0c;并且在策略实盘运行过程中&#xff0c;很难提供一个资金曲线进行查看&#xff0c;我开发了一款资金曲线分时图工具&#xff0c;可以将期货CTP账户的资金曲线绘制出来&#xff0c;方便检查实盘策略中的…

HCIA第二天笔记

思维导图 HCIA第二天笔记 IP报文头部 图 第二行分别是&#xff1a;标识字段&#xff0c;标志位和片偏移字段 标识字段&#xff1a;相当于序列号&#xff0c;假设给第一个分片的报文序号随即为x则后续的每个报文1 标志位&#xff1…

鸿蒙系统走进大学课堂,华为鸿蒙系统HarmonyOS课程走进高校,武汉大学等高校将授课...

推动华为鸿蒙系统HarmonyOS高速发展的机会来了&#xff0c;当前已得到权威确定&#xff0c;华为鸿蒙系统HarmonyOS课程将走进高校&#xff0c;在武汉大学等15个高校将正式开展harmonyOS授课。据业内人士表示&#xff0c;此举将推动鸿蒙系统HarmonyOS在国内的普及&#xff0c;包…

HCIA (学习笔记二)

华为eNSP 以上图拓扑图为例 增加拓展结构 可以在此对路由器进行拓展 将所需的拓展面板拖进拓展板即可 配置 华为根据所属权限不同把设备分为不同的视图 <huawei> 尖括号为用户视图—只有查看权限 [huawei] 方括号为系统视图—可以进行全局配置 [gaomin-GigabitEthern…

HCIA-HarmonyOS Application Developer——题目集3

题目1 1、&#xff08;多选&#xff09;开发者在使用JavaUl框架时&#xff0c;会用到各种组件来创建一个页面&#xff0c;以下哪些XML属性&#xff0c;是所有组件通用的? A、id B、width C、theme D、clickable 解析&#xff1a;&#xff08;ABCD&#xff09; 题目2 2、&…