当前位置:网站首页>远程办公期间,项目小组微信群打卡 | 社区征文
远程办公期间,项目小组微信群打卡 | 社区征文
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('发送成功')
边栏推荐
- Coredns modifying upstream
- Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
- 总结的一些内存问题
- 1. Summary of wechat applet page Jump methods; 2. the navigateto stack does not jump to the tenth floor
- 去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
- 机器学习适合女生学吗?
- 手机上怎么开股票账户?另外,手机开户安全么?
- 交易所系统开发如何开发?数字货币交易所系统开发成熟技术案例
- 部门新来了个阿里25K出来的,让我见识到了什么是天花板
- Development techniques - import files using easyexcel (simple example)
猜你喜欢

分享十万级TPS的IM即时通讯综合消息系统的架构

Spark - understand partitioner in one article

What if the taskbar is blank after win11 update? Solution to blank and stuck taskbar after win11 update

MFC interface library bcgcontrolbar v33.0 - desktop alarm window, grid control upgrade, etc

latex字母头顶两个点

Niubi | the tools I have treasured for many years have made me free to fish with pay

How to use data sets in machine learning?

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

机器学习工作要求研究生吗?

Is machine learning suitable for girls?
随机推荐
What are database OLAP and OLTP? Same and different? Applicable scenarios
Is there a shortage? No need to download the free online resources! 2022 favorites must have it!
机器学习工作要求研究生吗?
How to design test cases
《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
深入解析 Apache BookKeeper 系列:第四篇—背压
100 important knowledge points that SQL must master: creating and manipulating tables
MFC interface library bcgcontrolbar v33.0 - desktop alarm window, grid control upgrade, etc
Golang application ━ installation, configuration and use of Hugo blog system
Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
The programmer's girlfriend gave me a fatigue driving test
How to develop the exchange system? Mature technology case of digital currency exchange system development
[backtracking] full arrangement II leetcode47
《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19
RP prototype resource sharing - shopping app
leetcode:104. 二叉树的最大深度
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
10 airbags are equipped as standard, and Chery arizer 8 has no dead corner for safety protection
Ten of the most heart piercing tests / programmer jokes, read the vast crowd, how to find?