企业微信常用接口

官方文档地址:https://work.weixin.qq.com/api/doc/90000/90135/90664
1.企业微信获取token

key value
url地址 https://qyapi.weixin.qq.com/cgi-bin/gettoken
请求类型 get
请求参数 corpid(String 企业Id)、corpsecret(String 企业应用密码)

2.根据手机号获取userId

key value
url地址 https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=ACCESS_TOKEN
请求类型 post
请求参数 mobile(String 手机号)、access_token(String token)

3.根据userID发送应用卡片消息

key value
url地址 https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN
请求类型 post
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用 Python 与企业微信进行交互,需要使用企业微信提供的 API 接口企业微信提供了多种接口,包括发送消息、获取用户信息、部门信息等等。以下是使用 Python 调用企业微信接口的基本步骤: 1. 获取企业微信 API 凭证:需要在企业微信后台管理应用中心创建一个应用,并获取应用的 Secret 和 AgentId。 2. 安装 Python 的 requests 模块:requests 是一个常用的 Python HTTP 库,可以方便地进行 HTTP 请求和响应处理。 3. 调用企业微信接口:使用 Python 的 requests 模块发送 HTTP 请求,调用企业微信提供的 API 接口。 下面是一个使用 Python 发送企业微信消息的示例代码: ```python import requests # 企业微信 API 凭证 corpid = 'your_corpid' corpsecret = 'your_corpsecret' agentid = 'your_agentid' # 获取 access_token url = f'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpid}&corpsecret={corpsecret}' response = requests.get(url) access_token = response.json().get('access_token') # 发送文本消息 url = f'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={access_token}' data = { "touser": "@all", "msgtype": "text", "agentid": agentid, "text": { "content": "Hello, World!" }, "safe": 0 } response = requests.post(url, json=data) print(response.text) ``` 以上示例代码中,我们使用 Python 的 requests 模块发送了一个文本消息,包括接收人、消息类型、应用 ID、消息内容等信息。企业微信消息 API 文档中还提供了其他消息类型和参数,可以根据需要进行调用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值