当前位置:网站首页>During telecommuting, the project team punched in the wechat group | solicited papers from the community
During telecommuting, the project team punched in the wechat group | solicited papers from the community
2022-06-30 22:33:00 【InfoQ】
Project preparation
- VSCode: To write code
- Python: The main development language
- An enterprise wechat : You need administrator rights
- The server : If it's just learning , Not really .
1. Log in to enterprise wechat

2. Create an


3. obtain AgentId and Secret

3. install Python Of requests library
pip install requests
import json
import urllib.parse
import requests
corpid = 'xxxxxxxx' # Enterprises ID
corpsecret = 'xxxxxxx' # application Secret
touser = 'xxxxxxxx' # Users receiving messages
agentid = 1000003 # application ID
base = 'https://qyapi.weixin.qq.com'
# 1. request access_token
access_token_api = urllib.parse.urljoin(base, '/cgi-bin/gettoken')
params = {'corpid': corpid, 'corpsecret': corpsecret}
response = requests.get(url=access_token_api, params=params).json()
access_token = response['access_token']
print(access_token)
# 2. Send a message
message_send_api = urllib.parse.urljoin(base, f'/cgi-bin/message/send?access_token={access_token}')
data = {'touser': touser,
'msgtype': 'text',
'agentid': agentid,
'text': {
'content': ' Hello , I'm a robot .'
}
}
response = requests.post(url=message_send_api, data=json.dumps(data)).json()
print(response['errcode'])
if response['errcode'] == 0:
print(' Send successfully ')


data = {'touser': touser,
'msgtype': 'text',
'agentid': agentid,
'text': {
'content': ' Hello , I'm a robot .'
}
}data = {'toparty': touser,
'msgtype': 'text',
'agentid': agentid,
'text': {
'content': ' Hello , I'm a robot .'
}
}
import json
import urllib.parse
import requests
corpid = 'xxxxx' # Enterprises ID
corpsecret = 'xxxx' # application Secret
touser = '2' # The user group that receives the message
agentid = 1000003 # application ID
base = 'https://qyapi.weixin.qq.com'
# 1. request access_token
access_token_api = urllib.parse.urljoin(base, '/cgi-bin/gettoken')
params = {'corpid': corpid, 'corpsecret': corpsecret}
response = requests.get(url=access_token_api, params=params).json()
access_token = response['access_token']
# 2. Send a message
message_send_api = urllib.parse.urljoin(base, f'/cgi-bin/message/send?access_token={access_token}')
data = {'toparty': touser, 'msgtype': 'text', 'agentid': agentid, 'text': {'content': ' Hello , I'm a robot .'}}
response = requests.post(url=message_send_api, data=json.dumps(data)).json()
print(response['errcode'])
if response['errcode'] == 0:
print(' Send successfully ')
边栏推荐
- Graduation project
- [micro service ~nacos] configuration center of Nacos
- 【Android,Kotlin,TFLite】移动设备集成深度学习轻模型TFlite(物体检测篇)
- How to change the win11 computer name? Win11 method of changing computer name
- Win11如何优化服务?Win11优化服务的方法
- Neo4j load CSV configuration and use
- Uniapp life cycle / route jump
- Some memory problems summarized
- Redis的事务和锁机制
- 多線程經典案例
猜你喜欢

Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing

Redis的事务和锁机制

As the public cloud market enters the deep water, can the calm Amazon cloud still sit still?

2022中国国潮发展新动向

Label Contrastive Coding based Graph Neural Network for Graph Classification

从PG15 XID64再次跳票说起

latex中 & 号什么含义?

项目管理到底管的是什么?

【BSP视频教程】BSP视频教程第19期:单片机BootLoader的AES加密实战,含上位机和下位机代码全开源(2022-06-26)

latex字母头顶两个点
随机推荐
多线程经典案例
Golang application ━ installation, configuration and use of Hugo blog system
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
[BSP video tutorial] BSP video tutorial issue 19: AES encryption practice of single chip bootloader, including all open source codes of upper and lower computers (June 26, 2022)
B_ QuRT_ User_ Guide(35)
Apache server OpenSSL upgrade
[golang] golang实现截取字符串函数SubStr
分享十万级TPS的IM即时通讯综合消息系统的架构
[introduction to MySQL] the first conversation · first time in the "database" Mainland
Uniapp third party network request
公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
KVM IO performance test data
项目管理到底管的是什么?
Uniapp routing uni simple router
【BSP视频教程】BSP视频教程第19期:单片机BootLoader的AES加密实战,含上位机和下位机代码全开源(2022-06-26)
Analysis of PostgreSQL storage structure
AtCoder Beginner Contest 255
The Sandbox 正在 Polygon 网络上进行部署
d编译时计数
Niubi | the tools I have treasured for many years have made me free to fish with pay