微信api接口,加好友及通过好友请求

/**

* 微信自动添加好友

* @author wechatno:tangjinjinwx

* @blog http://www.wlkankan.cn

*/

@Async

public void handleMsg(ChannelHandlerContext ctx ,TransportMessage vo, String contentJsonStr) {

try {

log.debug(contentJsonStr);

FriendAddTaskSetting req = JSON.parseObject(contentJsonStr,FriendAddTaskSetting.class);

if(null != req){

String resp ="fail";

resp = friendAddTaskService.savePcTask(req);

//3、告诉PC客户端消息已收到

MessageUtil.sendCustomJsonMsg(ctx, "AutoFriendAddTaskResp", resp);

}

} catch (Exception e) {

e.printStackTrace();

MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);

}

}

/**

* 微信新增好友通知

* @author wechatno:tangjinjinwx

* @blog http://www.wlkankan.cn

*/

@Async

public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

try {

FriendAddNoticeMessage req = vo.getContent().unpack(FriendAddNoticeMessage.class);

//把消息转发给pc端

asyncTaskService.msgSend2pc(req.getWeChatId(), EnumMsgType.FriendAddNotice, req);

//保存新增好友

asyncTaskService.saveFriendAddContactinfo(req);

//告诉客户端消息已收到

MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);

} catch (Exception e) {

e.printStackTrace();

MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), Constant.ERROR_MSG_DECODFAIL);

}

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐