当前位置:网站首页>远程办公期间,项目小组微信群打卡 | 社区征文
远程办公期间,项目小组微信群打卡 | 社区征文
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('发送成功')
边栏推荐
- The Three Musketeers: One for All!
- 十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
- Gartner focuses on low code development in China how UNIPRO practices "differentiation"
- Pytorch quantitative practice (1)
- Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
- Turn: win others' follow with practical actions
- JVM Part 21 of interview with big companies Q & A
- How does win11 optimize services? Win11 method of optimizing service
- Modify the name of the launched applet
- 在启牛开的股票账户安全吗?如何申请低佣金的股票账户?
猜你喜欢
随机推荐
Uniapp routing uni simple router
国产数据库乱象
Analysis of PostgreSQL storage structure
《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19
请指教同花顺软件究竟是什么?另外想问,现在在线开户安全么?
与AI结对编程式是什么体验 Copilot vs AlphaCode, Codex, GPT-3
去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
基于kubernetes平台微服务的部署
Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing
Document layout analysis: a comprehensive survey 2019 paper learning summary
Niubi | the tools I have treasured for many years have made me free to fish with pay
Microservice link risk analysis
Ten of the most heart piercing tests / programmer jokes, read the vast crowd, how to find?
Coredns modifying upstream
What is the experience of pairing with AI? Pilot vs alphacode, Codex, gpt-3
msf之ms17-010永恒之蓝漏洞
Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
[backtracking] full arrangement leetcode46
B_ QuRT_ User_ Guide(35)
1. Summary of wechat applet page Jump methods; 2. the navigateto stack does not jump to the tenth floor