当前位置:网站首页>Wechat: get the owner of a single tag
Wechat: get the owner of a single tag
2022-04-23 08:46:00 【HezhezhiyuLe】
Preface
The actual business scenario may require everyone under a label , Do some specified operations , So a tool class is created to get all the people under the tag
Code
@Autowired
private RestTemplate restTemplate;
private String smSpToken;
/** * Query everyone under the tag * @param tag label ID Required * @return Personnel in the label openid */
public List<String> findUserByTag(int tag){
ArrayList<String> openids = new ArrayList<>();
// WeChat token
String smSpToken="";
// next ID The first one is empty by default
String openid="";
// The number of cycles is more specific to how many people write your label 10000 people in a cycle
for (int i = 0; i < 40; i++) {
System.out.println(" The first "+i);
String url="https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token="+smSpToken;
TagWxUser tagWxUser = new TagWxUser();
tagWxUser.setTagid(tag);
tagWxUser.setNext_openid(openid);
String param=JSON.toJSONString(tagWxUser);;
System.out.println(param);
// Custom sending method
String body = restTemplate.postForEntity(url, param, String.class).getBody();
if(body.contains("errcode")){
System.out.println(body);
continue;
}
if(body!=null&&!"".equals(body)){
JSONObject jsonObject = JSONObject.fromObject(body);
int count = jsonObject.getInt("count");
if(count==0){
// the last one ID The return value is 0
System.out.println(body);
System.out.println(" End of acquisition "+i+" "+openids.size()+" %%"+" "+body);
break;
}
// Parse the return value
String next_openid = jsonObject.getString("next_openid");
if(next_openid!=null&&!"".equals(next_openid)){
System.out.println(" next :"+next_openid);
openid=next_openid;
String data = jsonObject.getString("data");
if(data!=null&&!"".equals(data)){
JSONObject jsonObject2 = JSONObject.fromObject(data);
String tagopenid = jsonObject2.getString("openid");
if(tagopenid!=null&&!"".equals(tagopenid)){
List<String> arr = JSON.parseArray(tagopenid, String.class);
if(arr!=null&&arr.size()>0){
openids.addAll(arr);
}
}
}
}
}
}
return openids;
}
版权声明
本文为[HezhezhiyuLe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230839448097.html
边栏推荐
- LINQ学习系列-----1.4 匿名对象
- Anonymous type (c Guide Basics)
- 'bully' Oracle enlarged its move again, and major enterprises deleted JDK overnight...
- Solidity 问题汇总
- After a circle, I sorted out this set of interview questions..
- 单片机数码管秒表
- Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting
- Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library
- Large amount of data submitted by form post
- Latex paper typesetting operation
猜你喜欢

洋桃电子STM32物联网入门30步笔记一、HAL库和标准库的区别

HAL库的RCC简介

Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library

汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告

SYS_ CONNECT_ BY_ Path (column, 'char') combined with start with connect by prior

Redis Desktop Manager for Mac(Redis可视化工具)

2022-04-22 OpenEBS云原生存储

计算神经网络推理时间的正确方法

面了一圈,整理了这套面试题。。

Solidity 问题汇总
随机推荐
RCC introduction of Hal Library
洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解
Judgment on heap (25 points) two insertion methods
洋桃电子STM32物联网入门30步笔记三、CubeMX图形化编程、设置开发板上的IO口
Learn SQL injection in sqli liabs (Level 11 ~ level 20)
深度学习框架中的自动微分及高阶导数
Excle plus watermark
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
Search tree judgment (25 points)
Consensus Token:web3.0生态流量的超级入口
关于数组复制问题
Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library
Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting
Add random attributes to the Li class array objects and sort them
Complete binary search tree (30 points)
idea底栏打开services
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
bashdb下载安装
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
L2-024 部落 (25 分)(并查集)