参数说明
参数 | 是否必填 | 说明 |
msgtype | 是 | 消息类型,此时固定为markdown |
content | 是 | markdown内容,最长不超过4096个字节,必须是utf8编码 |
效果展示
Demo Code
# -*- coding: utf-8 -*-
# coding:unicode_escape
# Created on 2021年12月31日
# @author: LinHuang(Joker)
import requests
import json
# mian function
def main():
oWX_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=50d640d9-9ad6-4d39-98aa-c94c200212345'
sent_msg = {
"msgtype": "markdown", # "消息类型,此时固定为markdown
"markdown": {
"content": "Any question you can find answer in here:[Joker''s Blog](https: // blog.csdn.net/huanglin6)" #"markdown内容,最长不超过4096个字节,必须是utf8编码
}
} # 转换为json字符串
headers = {'Content-Type': 'application/json'} # 指定提交的是json
try:
r = requests.post(url=oWX_URL, data=json.dumps(sent_msg), headers=headers, timeout=5)
except Exception as e:
print(e.args[0])
if __name__ == '__main__':
main()