1、回调
看了官方文档一直不清楚怎么配回调的地址,发现有多中方式的回调,一度认为需要配置多个接口才对,后翻阅大量资料发现:
官方给的回调地址参考:https://www.example.com?SdkAppid=KaTeX parse error: Expected ‘EOF’, got ‘&’ at position 9: SDKAppID&̲CallbackCommand…CallbackCommand&contenttype=json&ClientIP=KaTeX parse error: Expected ‘EOF’, got ‘&’ at position 9: ClientIP&̲OptPlatform=OptPlatform
注意这个参数:CallbackCommand
固定为 C2C.CallbackAfterSendMsg

也就是通过这个参数去判断,这里给的是单聊发送后回调。

我这边配的本地地址参考:
http://192.168.2.12:8089/im/api/resultCode” />

@Service@Datapublic class UserSigService {    @Value("${IMConfig.portImport}")    private String portImport;    @Value("${IMConfig.portCheck}")    private String portCheck;    @Value("${IMConfig.portSendMsg}")    private String portSendMsg;    @Value("${IMConfig.sdkappid}")    private Long sdkappid;    @Value("${IMConfig.secrekey}")    private String secrekey;    @Value("${IMConfig.identifier}")    private String identifier;    private Long random= Random32.random32();    @Value("${IMConfig.contenttype}")    private String contenttype;    private long exprie=60*60*24*7;    public String generateUserSig(String userId){        TLSSigAPIv2 api = new TLSSigAPIv2(sdkappid,secrekey);        return api.genSig(userId,exprie);    }

发送请求(导入账号):

@Overridepublic JSONObject  importIm(UserEntity body) {   //https://console.tim.qq.com/v4/im_open_login_svc/account_import?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json   String userSig=userSigService.generateUserSig(userSigService.getIdentifier());   String url = "https://console.tim.qq.com/"+ userSigService.getPortImport()+"?usersig="+userSig+"&identifier="+userSigService.getIdentifier()         +"&sdkappid="+userSigService.getSdkappid()+"&contenttype="+userSigService.getContenttype();   HttpHeaders headers = new HttpHeaders();   Map<String,String> map = new HashMap<>();   map.put("UserID",body.getUsername());   map.put("Nick",body.getNickName());   map.put("FaceUrl",body.getFaceUrl());   HttpEntity<Map<String,String>> requestEntity = new HttpEntity<Map<String,String>>(map, headers);   SSLRestTemplate sslRestTemplate = new SSLRestTemplate();   ResponseEntity<JSONObject> exchange = sslRestTemplate.exchange(url, HttpMethod.POST, requestEntity, JSONObject .class);   JSONObject  bodyOne = exchange.getBody();   return bodyOne;}