微信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

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐