参数说明
参数 | 是否必填 | 说明 |
---|
msgtype | 是 | 消息类型,此时固定为template_card |
template_card | 是 | 具体的模版卡片参数 |
template_card的参数说明
参数 | 是否必填 | 说明 |
---|
card_type | 是 | 模版卡片的模版类型,文本通知模版卡片的类型为text_notice |
source | 否 | 卡片来源样式信息,不需要来源样式可不填写 |
source.icon_url | 否 | 来源图片的url |
source.desc | 否 | 来源图片的描述,建议不超过13个字 |
main_title | 是 | 模版卡片的主要内容,包括一级标题和标题辅助信息 |
main_title.title | 是 | 一级标题,建议不超过26个字 |
main_title.desc | 否 | 标题辅助信息,建议不超过30个字 |
emphasis_content | 否 | 关键数据样式 |
emphasis_content.title | 否 | 关键数据样式的数据内容,建议不超过10个字 |
emphasis_content.desc | 否 | 关键数据样式的数据描述内容,建议不超过15个字 |
sub_title_text | 否 | 二级普通文本,建议不超过112个字 |
horizontal_content_list | 否 | 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 |
horizontal_content_list.type | 否 | 链接类型,0或不填代表是普通文本,1 代表跳转url,2 代表下载附件 |
horizontal_content_list.keyname | 是 | 二级标题,建议不超过5个字 |
horizontal_content_list.value | 否 | 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字 |
horizontal_content_list.url | 否 | 链接跳转的url,horizontal_content_list.type是1时必填 |
horizontal_content_list.media_id | 否 | 附件的media_id,horizontal_content_list.type是2时必填 |
jump_list | 否 | 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 |
jump_list.type | 否 | 跳转链接类型,0或不填代表不是链接,1 代表跳转url,2 代表跳转小程序 |
jump_list.title | 是 | 跳转链接样式的文案内容,建议不超过13个字 |
jump_list.url | 否 | 跳转链接的url,jump_list.type是1时必填 |
jump_list.appid | 否 | 跳转链接的小程序的appid,jump_list.type是2时必填 |
jump_list.pagepath | 否 | 跳转链接的小程序的pagepath,jump_list.type是2时选填 |
card_action | 是 | 整体卡片的点击跳转事件,text_notice模版卡片中该字段为必填项 |
card_action.type | 否 | 卡片跳转类型,0或不填代表不是链接,1 代表跳转url,2 代表打开小程序。text_notice模版卡片中该字段取值范围为[1,2] |
card_action.url | 否 | 跳转事件的url,card_action.type是1时必填 |
card_action.appid | 否 | 跳转事件的小程序的appid,card_action.type是2时必填 |
card_action.pagepath | 否 | 跳转事件的小程序的pagepath,card_action.type是2时选填 |
效果展示

Demo Code
import requests
import json
def main():
oWX_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=50d640d9-9ad6-4d39-98aa-c94c2002e6d4'
data={
"msgtype":"template_card",
"template_card":{
"card_type":"text_notice",
"source":{
"icon_url":"http://119.29.121.148/ui5/com.joker.shop/uimodule/webapp/img/ShopCarouselShipping.jpg",
"desc":"Joker's Blog",
"desc_color":0
},
"main_title":{
"title":"欢迎使用CSDN",
"desc":"您的好友正在邀请您加入CSDN"
},
"emphasis_content":{
"title":"Joker",
"desc":"Joker's Blog"
},
"quote_area":{
"type":1,
"url":"https://blog.csdn.net/",
"appid":"APPID",
"pagepath":"PAGEPATH",
"title":"Joker",
"quote_text":"Joker:Joker的博客真的很好用~\nBalian:很多很棒的技术文章!"
},
"sub_title_text":"下载CSDN还能抢红包!",
"horizontal_content_list":[
{
"keyname":"邀请人",
"value":"Joker"
},
{
"keyname":"CSDN官网",
"value":"点击访问",
"type":1,
"url":"https://blog.csdn.net/"
}
],
"jump_list":[
{
"type":1,
"url":"https://blog.csdn.net/huanglin6",
"title":"Joker"
}
],
"card_action":{
"type":1,
"url":"https://blog.csdn.net/huanglin6",
"appid":"APPID",
"pagepath":"PAGEPATH"
}
}
}
headers = {'Content-Type': 'application/json'}
try:
response = requests.post(url=oWX_URL, json=data, headers=headers, timeout=5)
except Exception as e:
print(e.args[0])
if __name__ == '__main__':
main()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架