快捷搜索:

个人微信api接口调用-发微信朋友圈、拉取朋友圈数据功能

个人微信api接口调用-发微信朋友圈、拉取朋友圈数据功能

推送微信朋友圈列表
     /**
     * 触发推送朋友圈列表
     * @author wechatno:tangjinjinwx 
     * @blog http://www.wlkankan.cn
     */
    @Async
    public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo, String contentJsonStr) {
        try {
            log.debug(contentJsonStr);
            TriggerCirclePushTaskMessage.Builder bd = TriggerCirclePushTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            TriggerCirclePushTaskMessage req = bd.build();
            // TriggerCirclePushTaskMessage req =
            // vo.getContent().unpack(TriggerCirclePushTaskMessage.class);
            // 将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, req.getWeChatId(), EnumMsgType.TriggerCirclePushTask, vo, req);
        } 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 {
            CirclePushNoticeMessage req = vo.getContent().unpack(CirclePushNoticeMessage.class);
            log.debug(JsonFormat.printer().print(req));
            //把消息转发给pc端
            asyncTaskService.msgSend2pc(req.getWeChatId(), EnumMsgType.CirclePushNotice, req);
            //保存朋友圈信息
            asyncTaskService.asyncSaveCircleMsg(req, circleService, weChatContactService);
            //告诉客户端消息已收到
            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);
        }
    }

个人微信api接口调用-发微信朋友圈,拉取朋友圈数据

发微信朋友圈  

    /**
     * 发微信朋友圈
     * @author wechatno:tangjinjinwx
     * @blog http://www.wlkankan.cn
     */

    @Async
    public  void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
        try {
            log.debug(contentJsonStr);
            PostSNSNewsTaskMessage.Builder bd = PostSNSNewsTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            PostSNSNewsTaskMessage req = bd.build();
            //PostSNSNewsTaskMessage req = vo.getContent().unpack(PostSNSNewsTaskMessage.class);
              
            asyncTaskService.msgSend2Phone(ctx, req.getWeChatId(), EnumMsgType.PostSNSNewsTask, vo, req);
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

以上代码依赖微信开发SDK,微信api接口方案咨询微信happybabby110

微信聚合聊天客服系统--微信SDK方案演示系统

拓展阅读:http://www.wlkankan.cn/cate41/301.html



文章来自:微赚淘客
分享地址:/bbs/cate40/211319.html