当前位置:网站首页>远程办公期间,项目小组微信群打卡 | 社区征文
远程办公期间,项目小组微信群打卡 | 社区征文
2022-06-30 22:16:00 【InfoQ】
项目准备
- VSCode:用来写代码
- Python: 主要的开发语言
- 一个企业微信:需要有管理员权限
- 服务器:如果只是学习的话,就不需要了。
1. 登录企业微信

2. 创建应用


3. 获取AgentId和Secret

3. 安装Python的requests库
pip install requests
import json
import urllib.parse
import requests
corpid = 'xxxxxxxx' # 企业ID
corpsecret = 'xxxxxxx' # 应用Secret
touser = 'xxxxxxxx' # 接收消息的用户
agentid = 1000003 # 应用ID
base = 'https://qyapi.weixin.qq.com'
# 1.请求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.发送消息
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': '你好,我是机器人。'
}
}
response = requests.post(url=message_send_api, data=json.dumps(data)).json()
print(response['errcode'])
if response['errcode'] == 0:
print('发送成功')


data = {'touser': touser,
'msgtype': 'text',
'agentid': agentid,
'text': {
'content': '你好,我是机器人。'
}
}data = {'toparty': touser,
'msgtype': 'text',
'agentid': agentid,
'text': {
'content': '你好,我是机器人。'
}
}
import json
import urllib.parse
import requests
corpid = 'xxxxx' # 企业ID
corpsecret = 'xxxx' # 应用Secret
touser = '2' # 接收消息的用户组
agentid = 1000003 # 应用ID
base = 'https://qyapi.weixin.qq.com'
# 1.请求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.发送消息
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': '你好,我是机器人。'}}
response = requests.post(url=message_send_api, data=json.dumps(data)).json()
print(response['errcode'])
if response['errcode'] == 0:
print('发送成功')
边栏推荐
- Develop technology - get time 10 minutes ago
- 与AI结对编程式是什么体验 Copilot vs AlphaCode, Codex, GPT-3
- latex左侧大括号 latex中大括号多行公式
- Is Wu Enda's machine learning suitable for entry?
- Turn: win others' follow with practical actions
- Analysis of PostgreSQL storage structure
- Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
- Femas:云原生多运行时微服务框架
- 交易所系统开发如何开发?数字货币交易所系统开发成熟技术案例
- Uniapp rich text editor
猜你喜欢

基于kubernetes平台微服务的部署
Notes [introduction to JUC package and future]

Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes

Where can I find the computer version of wechat files

Do machine learning jobs require graduate students?

latex左侧大括号 latex中大括号多行公式
![[introduction to MySQL] the first conversation · first time in the](/img/73/cc85eb469384c3df94479318293c6f.png)
[introduction to MySQL] the first conversation · first time in the "database" Mainland

多线程经典案例

Uniapp life cycle / route jump

深入解析 Apache BookKeeper 系列:第四篇—背压
随机推荐
Femas: cloud native multi runtime microservice framework
Turn: win others' follow with practical actions
Anfulai embedded weekly report no. 270: June 13, 2022 to June 19, 2022
Zhoushaojian, rare
《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
Where can I find the computer device manager
Store Nagios monitoring information into MySQL
Apache server OpenSSL upgrade
基于kubernetes平台微服务的部署
Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
WinDbg debugging tool introduction
latex中 & 号什么含义?
msf之ms17-010永恒之蓝漏洞
[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)
Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
Mysql:sql overview and database system introduction | dark horse programmer
公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
吴恩达的机器学习适合入门吗?
leetcode:104. 二叉树的最大深度