💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
抖音sdk,抖音api接口 ,抖音apijava调用源码 1、抖音上线下线 /** * 抖音上线通知 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { ImOnlineNoticeMessage req = vo.getContent().unpack(ImOnlineNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); //1、校验用户信息 if(null != req){ //2、存储全局id 与通道 NettyConnectionUtil.registerUserid(req.getImUid(),ctx); DeviceInfo device = deviceService.getByDeviceid(req.getImei()); if(null != device){ //做个保护,如果当前微信号在其他设备上登陆过,就把之前那条记录删除 if(!StringUtils.isBlank(req.getImUid()) && !StringUtils.isBlank(req.getImei())){ if(!StringUtils.isEmpty(device.getImuid()) && !req.getImUid().equals(device.getImuid())){ device.setAvatar(""); device.setImuid(""); device.setNickname(""); device.setIsonline(1); deviceService.update(device); } } //设置新的参数 device.setImuid(req.getImUid()); device.setNickname(req.getNickName()); device.setAvatar(req.getAvatar()); device.setGender(req.getGenderValue()); device.setPhone(req.getPhone()); device.setUniqueid(req.getUniqueId()); device.setProvince(req.getProvince()); device.setCity(req.getCity()); device.setDistrict(req.getDistrict()); device.setSignature(req.getSignature()); device.setAwemecount(req.getAwemeCount()); device.setFollowingcount(req.getFollowingCount()); device.setFollowercount(req.getFollowerCount()); device.setFriendcount(req.getFriendCount()); //改为上线状态 device.setIsonline(0);//上线 deviceService.update(device); //3、告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ImOnlineNotice, req); } } } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage()); } } /** * 抖音下线通知 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { ImOfflineNoticeMessage req = vo.getContent().unpack(ImOfflineNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); if (null != req) { // 把消息转发给pc端 DeviceInfo account = deviceService.getByImUid(req.getImUid()); if (null != account) { account.setIsonline(1);// 下线 deviceService.update(account); asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ImOfflineNotice, req); } // 3、告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); } else { MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_ILLEGALDEVICE); } } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_DECODFAIL); } } 2、抖音粉丝或好友收发消息 /** * 给抖音粉丝或好友发消息 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); TalkToFriendTaskMessage.Builder bd = TalkToFriendTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); TalkToFriendTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.TalkToFriendTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } /** * 抖音聊天消息实时推送 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { ChatMsgNoticeMessage req = vo.getContent().unpack(ChatMsgNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); log.debug(LocalDateTime.now()+" ChatMsgNoticeMessage 对应的线程名: "+Thread.currentThread().getName()); //消息转发到pc端 asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ChatMsgNotice, req); // 告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage()); } } 3、关注与取消关注抖音号 /** * @author wechat:happybabby110 * @blog http://www.wlkankan.cn * 关注抖音号 */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); FollowTaskMessage.Builder bd = FollowTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); FollowTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.FollowTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } /** * 取消关注抖音号 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); UnFollowTaskMessage.Builder bd = UnFollowTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); UnFollowTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.UnFollowTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } 4、同步抖音推荐的好友 /** * 同步抖音推荐的好友 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); SyncRecFriendsTaskMessage.Builder bd = SyncRecFriendsTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); SyncRecFriendsTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncRecFriendsTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } /** * 推送抖音推荐的好友 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { RecFriendsPushNoticeMessage req = vo.getContent().unpack(RecFriendsPushNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); log.debug(LocalDateTime.now()+" RecFriendsPushNoticeMessage 对应的线程名: "+Thread.currentThread().getName()); //消息转发到pc端 asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.RecFriendsPushNotice, req); // 告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage()); } } 5、同步抖音聊天会话列表 /** * 同步抖音会话列表 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); SyncConversationTaskMessage.Builder bd = SyncConversationTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); SyncConversationTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncConversationTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } /** * 推送抖音会话列表 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { ConversationPushNoticeMessage req = vo.getContent().unpack(ConversationPushNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); log.debug(LocalDateTime.now()+" ConversationPushNoticeMessage 对应的线程名: "+Thread.currentThread().getName()); //消息转发到pc端 asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ConversationPushNotice, req); // 告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage()); } } 6、同步抖音粉丝列表 /** * 同步抖音粉丝 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) { try { log.debug(contentJsonStr); SyncFollowersTaskMessage.Builder bd = SyncFollowersTaskMessage.newBuilder(); JsonFormat.parser().merge(contentJsonStr, bd); SyncFollowersTaskMessage req = bd.build(); //将消息转发送给手机客户端 asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncFollowersTask, vo, req); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } } /** * 推送抖音粉丝 * @author wechat:happybabby110 * @blog http://www.wlkankan.cn */ @Async public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) { try { FollowersPushNoticeMessage req = vo.getContent().unpack(FollowersPushNoticeMessage.class); log.debug(JsonFormat.printer().print(req)); log.debug(LocalDateTime.now()+this.getClass().getName()+"对应的线程名: "+Thread.currentThread().getName()); //消息转发到pc端 asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.FollowersPushNotice, req); // 告诉客户端消息已收到 MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); } catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage()); } } 抖音api接口,抖音sdk方案咨询微信happybabby110