From dd92541b17b777acff81046bffc22dd5f7f49a22 Mon Sep 17 00:00:00 2001 From: 3y Date: Tue, 31 Jan 2023 20:57:31 +0800 Subject: [PATCH] update delfan --- .../controller/OfficialAccountController.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/OfficialAccountController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/OfficialAccountController.java index cf14aac..a168fdf 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/controller/OfficialAccountController.java +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/OfficialAccountController.java @@ -2,7 +2,9 @@ package com.java3y.austin.web.controller; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.Header; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.google.common.base.Throwables; @@ -54,6 +56,7 @@ public class OfficialAccountController { @Autowired private StringRedisTemplate redisTemplate; + /** * @param id 账号Id * @return @@ -212,16 +215,19 @@ public class OfficialAccountController { @ApiOperation("/删除测试号的测试用户") public BasicResultVO deleteTestUser(HttpServletRequest request) { try { - String cookie = request.getHeader("Cookie"); - List openIds = loginUtils.getLoginConfig() - .getOfficialAccountLoginService().getUserService().userList(null).getOpenids(); + + // 删除粉丝 + String testUrl = "http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo"; + String action = "delfan"; + + String cookie = request.getHeader(Header.COOKIE.getValue()); + List openIds = loginUtils.getLoginConfig().getOfficialAccountLoginService().getUserService().userList(null).getOpenids(); for (String openId : openIds) { Map params = new HashMap<>(4); params.put("openid", openId); - params.put("random", "0.859336489537766"); - params.put("action", "delfan"); - HttpUtil.createPost("http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo") - .header("Cookie", cookie).form(params).execute(); + params.put("random", RandomUtil.randomDouble()); + params.put("action", action); + HttpUtil.createPost(testUrl).header(Header.COOKIE, cookie).form(params).execute(); } return BasicResultVO.success(); } catch (Exception e) {